SHARE
TWEET

Untitled

a guest Feb 15th, 2020 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<vector>
  3. #include<algorithm>
  4. using namespace std;
  5. int main() {
  6.     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  7.     /*fstream cin("input.txt");
  8.     ofstream cout("output.txt");*/
  9.     long long n,k, a;
  10.     cin >> n;
  11.     vector<long long> sums;
  12.     sums.push_back(0);
  13.     for (int i = 0; i < n; i++) {
  14.         cin >> a;
  15.         sums.push_back(sums.back()+a);
  16.     }
  17.     cin >> k;
  18.     long long l, r;
  19.     for (int i = 0; i < k; i++) {
  20.         cin >> l >> r;
  21.         cout << sums[r] - sums[l-1] << endl;
  22.     }
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top