Pagini recente » Cod sursa (job #2552203) | Cod sursa (job #1251701) | Cod sursa (job #1966600) | Cod sursa (job #1852062) | Cod sursa (job #530805)
Cod sursa(job #530805)
var a:array[1..15000] of word;
v:array[1..15000] of longint;
n,x,y,r:word;
m,s,i,j: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);
r:=x;
while r<=n do
begin
v[r]:=v[r]-y;
r:=r+(r xor (r and (r-1)));
end;
end;
1: begin
readln(t,x,y);
s:=0;
r:=y;
while r>0 do
begin
s:=s+v[r];
r:=r-(r xor (r and (r-1)));
end;
r:=x-1;
while r>0 do
begin
s:=s-v[r];
r:=r-(r xor (r and (r-1)));
end;
writeln(f,s);
end;
end;
end;
close(t);
close(f);
end.