Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- using ll = long long;
- const int N = 1e5+10;
- ll arr[N], qs[N];
- int main()
- {
- int n, m;
- scanf("%d%d", &n, &m);
- for (int i = 1; i <= n; ++i) {
- scanf("%lld", &arr[i]);
- qs[i] = qs[i-1] + arr[i];
- }
- while (m--) {
- int a, b;
- scanf("%d%d", &a, &b);
- printf("%lld\n", qs[b]-qs[a-1]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement