0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 14:56:27 +00:00
Baoshuo Ren 2021-07-22 15:22:01 +08:00 committed by Baoshuo Ren
parent 0f19c2debc
commit 3e82fa10c7
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

18
AcWing/795/795.cpp Normal file
View File

@ -0,0 +1,18 @@
#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;
}