Pagini recente » Cod sursa (job #1324930) | Cod sursa (job #1269724) | Cod sursa (job #2550456) | Cod sursa (job #2009382) | Cod sursa (job #530720)
Cod sursa(job #530720)
var a,v:array[0..15000] of longint;
n,m,i,j,x,y,suma: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;
inc(x,(x xor (x and (x-1))));
end;
end;
1: begin
readln(t,x,y);
suma:=0;
while y>0 do
begin
suma:=suma+v[y];
dec(y,(y xor (y and (y-1))));
end;
if x>1 then
begin
dec(x);
while x>0 do
begin
suma:=suma-v[x];
dec(x,(x xor (x and (x-1))));
end;
end;
writeln(f,suma);
end;
end;
end;
close(t);
close(f);
end.