Submission
Status:
PPPPPPPPPPPPPPPPPPPP
Score: 100
User: NovemNotes
Problemset: ผลบวก (กลาง)
Language: cpp
Time: 0.057 second
Submitted On: 2024-10-24 15:34:35
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,q,k,a,b;
vector<ll> v;
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n;
v.push_back(0);
for(int i=1;i<=n;i++){
ll x;cin >> x;
v.push_back(x+v[i-1]);
}
cin >> q;
while(q--){
cin >> a >> b;
a++,b++;
cout << v[b] - v[a-1] << "\n";
}
return 0;
}