0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-08 19:18:47 +00:00

B - Fenwick Tree

https://atcoder.jp/contests/practice2/submissions/33500324
This commit is contained in:
Baoshuo Ren 2022-07-24 21:38:05 +08:00
parent d3eb18bfdd
commit 133b6d9da5
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

40
AtCoder/practice2/B/B.cpp Normal file
View File

@ -0,0 +1,40 @@
#include <iostream>
#include <atcoder/fenwicktree>
using std::cin;
using std::cout;
const char endl = '\n';
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, q;
cin >> n >> q;
atcoder::fenwick_tree<long long> tr(n);
for (int i = 0; i < n; i++) {
long long x;
cin >> x;
tr.add(i, x);
}
while (q--) {
int op;
long long x, y;
cin >> op >> x >> y;
if (op == 0) {
tr.add(x, y);
} else { // op == 1
cout << tr.sum(x, y) << endl;
}
}
return 0;
}