从简单题开始慢慢来
#include <iostream>
using namespace std;
const int N = 100010;
int n,m;
int a[N],s[N];
int main(){
cin>>n>>m;
for (int i = 1; i <= n;i ++){
cin>>a[i];
s[i] = s[i-1]+a[i];
}
while (m--){
int l,r,res;
cin>>l>>r;
res = s[r]-s[l-1];
cout<<res<<endl;
}
return 0;
}