ihydra1611
Rating
-
Bài tập
12
Điểm
5566
Rating #
-
Điểm #
8335
Giới thiệu
include <bits/stdc++.h>
define forr(i,l,r) for (int i=l;i<=r;i++)
define ford(i,r,l) for (int i=r;i>=l;i--)
define yes cout <<"YES\n"
define no cout <<"NO\n"
define fi first
define se second
define ull unsigned long long
define ll long long
define sz(s) s.size()
define el "\n"
define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
int a[100005];
int n;
void update(int i, int val){
while(i <= n ){
a[i]+= val;
i += (i&-i);
}
}
int get(int i){
int sum = 0;
while(i){
sum+=a[i];
i-=(i&-i);
}
return sum;
}
void solve(){
int q,x,u,v,t;
cin >> n;
cin >> q;
forr(i,1,n) {
cin >> x;
update(i,x);
}
while(q--){
cin >> t >> u >> v;
if(t == 1) update(u,v);
else {
if(u == 1) cout << get(v) << endl;
else cout << get(v)-get(u-1)<<endl;
}
}
}
signed main()
{ faster;
int t=1;
///cin >> t;
while(t--) solve();
return 0;
}