Pagini recente » Cod sursa (job #1541682) | Cod sursa (job #3222113) | Cod sursa (job #2469363) | Cod sursa (job #3192608) | Cod sursa (job #3211756)
#include <fstream>
using namespace std;
ifstream cin("datorii.in");
ofstream cout("datorii.out");
const int nmax = 15001;
int t[nmax], n;
void update(int poz, int val){
while(poz <= n){
t[poz] += val;
poz += poz&(-poz);
}
}
int query(int poz){
int rez = 0;
while(poz >= 1){
rez += t[poz];
poz &= (poz - 1);
}
return rez;
}
int main(){
int m;
cin >> n >> m;
for(int i = 1; i <= n; i++){
int x;
cin >> x;
update(i, x);
}
for(int i = 1; i <= m; i++){
int cer, x, y;
cin >> cer >> x >> y;
if(cer)
cout << query(y) - query(x - 1) << '\n';
else
update(x, -y);
}
return 0;
}