Advertisement
AquaBlitz11

TASK_045 - AquaBlitz11's Solution

Dec 31st, 2017
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. using ll = long long;
  6.  
  7. const int N = 1e5+10;
  8.  
  9. ll arr[N], qs[N];
  10.  
  11. int main()
  12. {
  13.     int n, m;
  14.     scanf("%d%d", &n, &m);
  15.     for (int i = 1; i <= n; ++i) {
  16.         scanf("%lld", &arr[i]);
  17.         qs[i] = qs[i-1] + arr[i];
  18.     }
  19.  
  20.     while (m--) {
  21.         int a, b;
  22.         scanf("%d%d", &a, &b);
  23.         printf("%lld\n", qs[b]-qs[a-1]);
  24.     }
  25.  
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement