Pagini recente » Cod sursa (job #2368309) | Cod sursa (job #1768999) | Cod sursa (job #1374586) | Cod sursa (job #2310434) | Cod sursa (job #530792)
Cod sursa(job #530792)
var a,v:array[0..15000] of word;
n,x:word;
m,i,j,y,s:longint;
f,t:text;
begin
assign(f,'datorii.out');
rewrite(f);
assign(t,'datorii.in');
reset(t);
readln(t,n,m);
for i:=1 to n do
begin
read(t,a[i]);
for j:=i-(i xor (i and (i-1)))+1 to i do
v[i]:=v[i]+a[j];
end;
for i:=1 to m do
begin
read(t,j);
case j of
0: begin
readln(t,x,y);
while x<=n do
begin
v[x]:=v[x]-y;
x:=x+(x xor (x and (x-1)));
end;
end;
1: begin
readln(t,x,y);
s:=0;
while y>0 do
begin
s:=s+v[y];
y:=y-(y xor (y and (y-1)));
end;
x:=x-1;
while x>0 do
begin
s:=s-v[x];
x:=x-(x xor (x and (x-1)));
end;
writeln(f,s);
end;
end;
end;
close(t);
close(f);
end.