Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n, q;
- cin >> n >> q;
- int a[n], b[2];
- for (int i = 0; i < n; i++) {
- cin >> a[i];
- }
- for (int i = 0; i < q; i++) {
- cin >> b[0] >> b[1];
- b[0]--;
- b[1]--;
- long long sum=0;
- for (int j = b[0]; j <= b[1]; j++) {
- sum += a[j];
- }
- cout << sum << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment