mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 18:48:48 +00:00
795. 前缀和
https://www.acwing.com/problem/content/submission/code_detail/6604420/
This commit is contained in:
parent
0f19c2debc
commit
3e82fa10c7
18
AcWing/795/795.cpp
Normal file
18
AcWing/795/795.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user