0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-27 10:31:58 +00:00
OI-codes/AcWing/795/795.cpp

19 lines
330 B
C++
Raw Normal View History

#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;
}