题目传送门
代码:
#include<bits/stdc++.h>
using namespace std;typedef long long LL;
const int maxn=50000+100;LL ans[maxn];int main(){int n;scanf("%d",&n);for(int i=1;i<=n;i++) scanf("%lld",&ans[i]),ans[i]+=ans[i-1];int m;scanf("%d",&m);while(m--){int ind,len;scanf("%d%d",&ind,&len);printf("%lld\n",ans[ind+len-1]-ans[ind-1]);}
}