0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-09 01:18:47 +00:00
OI-codes/AcWing/795/795.cpp

19 lines
330 B
C++

#include <bits/stdc++.h>
using namespace std;
int n, m, a, l, r, sum[100005];
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> a;
sum[i] = sum[i - 1] + a;
}
for (int i = 1; i <= m; i++) {
cin >> l >> r;
cout << sum[r] - sum[l - 1] << endl;
}
return 0;
}