Submission
Status:
PPPPPPPPPPPPPPPPPPPP
Score: 100
User: Nathlol2
Problemset: ผลบวก (กลาง)
Language: cpp
Time: 0.050 second
Submitted On: 2025-01-17 17:04:18
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
int a[n];
memset(a, 0, sizeof a);
int i = 0;
while(n--){
int x;
cin >> x;
if(i != 0)
a[i] += a[i - 1];
a[i] += x;
i++;
}
int t;
cin >> t;
while(t--){
int x, b;
cin >> x >> b;
cout << a[b] - a[x - 1] << '\n';
}
}