板子题
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 5;
int __t = 1, n, q;
int a[N], bit[N];
void update(int idx, int val) {
while (idx <= n) {
bit[idx] += val;
idx += idx & -idx;
}
}
int query(int idx) {
int sum = 0;
while (idx > 0) {
sum += bit[idx];
idx -= idx & -idx;
}
return sum;
}
void solve() {
cin >> n >> q;
for (int i = 1; i <= n; i++) {
cin >> a[i];
update(i, a[i]);
}
while (q--) {
int op, x, y;
cin >> op >> x >> y;
if (op == 1) {
update(x, y);
} else if (op == 2) {
cout << query(y) - query(x - 1) << '\n';
}
}
}
int32_t main() {
#ifdef ONLINE_JUDGE
ios::sync_with_stdio(false);
cin.tie(0);
#endif
// cin >> __t;
while (__t--)
solve();
return 0;
}

京公网安备 11010502036488号