View Code of Problem 3939

#include<iostream>
using namespace std;
int main(){
	int n,m,j;cin>>n>>j;
	long long a[100005];
	a[0]=0;
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		a[i]+=a[i-1];
	}
	while(j--){
		scanf("%d%d",&n,&m);
		printf("%d\n",a[m]-a[n-1]);
	}
}

Double click to view unformatted code.


Back to problem 3939