| 比赛 | 
    十一中校庆欢乐赛 | 
    评测结果 | 
    EEEEEEEEEE | 
    | 题目名称 | 
    求和问题 | 
    最终得分 | 
    0 | 
    | 用户昵称 | 
    Chenyao2333 | 
    运行时间 | 
    0.890 s  | 
    | 代码语言 | 
    C++ | 
    内存使用 | 
    1.84 MiB  | 
    | 提交时间 | 
    2014-10-23 18:12:59 | 
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
typedef long long LL;
const int MAXN=2e5+10;
LL sum[MAXN];
int main(){
	//freopen("in.txt","r",stdin);
	int N,M;
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		int tmp; scanf("%d",&tmp);
		sum[i]=sum[i-1]+tmp;
	}
	scanf("%d",&M);
	for(int i=1;i<=M;i++){
		int a,b; scanf("%d %d",&a,&b);
		if(a==0) a++;
		LL ans=sum[b]-sum[a-1];
		printf("%lld\n",ans);
	}
	return 0;
}