Submission
Status:
PPPPPPPPPPPPPPPPPPPP
Score: 100
User: Monasm
Problemset: ผลบวก (กลาง)
Language: cpp
Time: 0.138 second
Submitted On: 2024-09-29 16:33:01
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;cin >> n;
vector<int> arr(n),pref(n,0);
int sum = 0;
for(int i=0;i<n;i++){
cin >> arr[i];
sum+=arr[i];
pref[i] = sum;
}
int q;cin >> q;
while(q--){
int x,y;cin >> x >> y;
if(!x){
cout<<pref[y]<<endl;
}
else{
cout<< pref[y]-pref[x-1]<<endl;
}
}
return 0;
}