#include<bits/stdc++.h>
using namespace std;
#define I inline
#define gc getchar
#define W while
const int N = 500010; int tr[N], n, q; int lbt(int x) {return x & (-x);}
I void add(int x, int k) {for(; x <= n; x += lbt(x)) tr[x] += k;}
I int query(int x) {
int sum = 0;
for(; x; x -= lbt(x)) sum += tr[x];
return sum;
}
I void Read(int &x) {
x = 0; char ch = gc(); W(ch < '0' || ch > '9') ch = gc();
W(ch >= '0' && ch <= '9') x = x * 10 + (ch ^ 48), ch = gc();
}
I void Read(int &x, int &y) {Read(x), Read(y);}
int main() {
Read(n, q); for(int i = 1; i <= n; i++) {int x; Read(x); add(i, x);}
W(q--) {
int op, x, y; Read(op); scanf("%d%d", &x, &y);
if(op == 1) add(x, y);
else printf("%d\n", query(y) - query(x - 1));
}
return 0;
}剪贴板
剪贴板 so9eq979
剪贴板信息
剪贴板信息
- 收录
- 更新