单点修改 区间查询
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#define LL long long
using namespace std;
inline void wprint(LL x){
if (x>9) wprint(x/10);
putchar(x%10+'0');
}
inline void print(LL x){
if (x<0) x=-x,putchar('-');
wprint(x);
putchar('\n');
}
inline int wread(){
char c(getchar());int wans(0),flag(1);
while (c<'0'||c>'9'){if (c=='-') flag=-1;c=getchar();}
while (c>='0'&&c<='9'){wans=(wans<<3)+(wans<<1)+(c^48);c=getchar();}
return wans*=flag;
}
inline LL ll_wread(){
char c(getchar());LL wans((LL)0),flag((LL)1);
while (c<'0'||c>'9'){if (c=='-') flag=-1;c=getchar();}
while (c>='0'&&c<='9'){wans=(wans<<3)+(wans<<1)+(c^48);c=getchar();}
return wans*=flag;
}
struct node{int l,r;LL ans;}e[400010];
int n,m;
void make_tre(int a,int l,int r){
e[a].l=l;e[a].r=r;e[a].ans=0;
if (l==r){e[a].ans=ll_wread();return ;}
int mid = l+r >>1;
make_tre(a<<1, l, mid);make_tre(a<<1|1, mid+1, r);
e[a].ans=e[a<<1].ans + e[a<<1|1].ans;
}
void add_dian(int a,int pos,int k){
if (e[a].l==pos&&e[a].r==pos) {e[a].ans+=k;return ;}
int mid= e[a].l + e[a].r >>1;
if (pos<=mid) add_dian(a<<1, pos, k);
else add_dian(a<<1|1, pos, k);
e[a].ans=e[a<<1].ans+e[a<<1|1].ans;
}
LL fnd_qu(int a,int l,int r){
if (e[a].l>=l && e[a].r<=r ){return e[a].ans;}
int mid=e[a].l + e[a].r >>1;
if (r<=mid) return fnd_qu(a<<1,l,r);
else if (l>mid) return fnd_qu(a<<1|1, l, r);
else return fnd_qu(a<<1,l,r)+fnd_qu(a<<1|1, l, r);
}
int main(){
n=wread();
make_tre(1,1,n);
m=wread();
while (m--){
int opr(wread());
if (opr==1){
int pos(wread()),k(wread());
add_dian(1,pos,k);
}
else {
int x(wread()),y(wread());
print(fnd_qu(1,x,y));
}
}
return 0;
}