nguyenhoangthongnbk2006
Giới thiệu
include<bits/stdc++.h>
using namespace std;
define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
define ll long long
define pll pair<long long,long long>
define all(v) v.begin(),v.end()
define pb push_back
define pii pair<int,int>
define piii int,pair<int,int>
define bit(n,i) ((n>>i)&1)
define fi first
define sc second
define pdb pair<double,double>
define db double
define endl '\n'
const long long maxn=1e6+5;
const long long minn=-1e6;
const long long MOD=1e9+7;
const long long inf=1e18;
ll n,q,a[maxn],bit[maxn];
void update(int vt,int val){
while(vt<=n){
bit[vt]+=val;
vt+=(vt&-vt);
}
}
ll getsum(int vt){
ll ans=0;
while(vt){
ans+=bit[vt];
vt-=(vt&-vt);
}
return ans;
}
ll getsumdoan(int u,int v){
return getsum(v)-getsum(u-1);
}
void nhap(){
cin>>n>>q;
for(int i=1;i<=n;i++){
cin>>a[i];
update(i,a[i]);
}
}
void solve(){
for(int i=1;i<=q;i++){
int op;cin>>op;
if(op==1){
int vt,val;cin>>vt>>val;
update(vt,val);
}else{
int u,v;cin>>u>>v;
cout<<getsumdoan(u,v)<<endl;
}
}
}
int main(){
faster
nhap();
solve();
return 0;
}