Advertisement
luanaamorim

Untitled

Jul 31st, 2020
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #include <iostream>
  2. #define _ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  3.  
  4. using namespace std;
  5.  
  6. long long n, sum[200005], q, a, b;
  7.  
  8. int main()
  9. {_
  10. sum[0] = 0;
  11. cin >> n >> q;
  12. for (int i = 1; i <= n; i++)
  13. {
  14. cin >> a;
  15. sum[i] = sum[i - 1] + a;
  16. }
  17.  
  18. for (int i = 0; i < q; i++)
  19. {
  20. cin >> a >> b;
  21. cout << sum[b] - sum[a - 1] << endl;
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement