AcWing
795. 前缀和
#include <bits/stdc++.h>
using namespace std;
int n, m;
const int N = 100010;
int s[N];
int main(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
cin >> s[i];
s[i] += s[i - 1];
}
while(m --){
int l, r;
cin >> l >> r;
cout << s[r] - s[l - 1] << endl;
}
}