artemgf

Интервалы

Apr 15th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include <iostream>
  3. #include <conio.h>
  4. #include <string>
  5. #include <set>
  6. #include <map>
  7. #include <algorithm>
  8. #include <string>
  9. #include <math.h>
  10. #include <vector>
  11. #include <cmath>
  12.  
  13. using namespace std;
  14.  
  15. int main()
  16. {
  17.     long long n, q, k[100001], ki, j, i, prom=0;
  18.  
  19.     cin >> n;
  20.  
  21.     k[0] = 0;
  22.  
  23.     for (int o = 1; o <= n; o++)
  24.     {
  25.         cin >> ki;
  26.         prom += ki;
  27.         k[o] = prom;
  28.     }
  29.  
  30.     cin >> q;
  31.  
  32.     for (int o = 1; o <= q; o++)
  33.     {
  34.         cin >> i >> j;
  35.         cout << k[j] - k[i - 1] << endl;
  36.     }
  37.     system("pause");
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment