Advertisement
Guest User

Untitled

a guest
Feb 15th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement