Pagini recente » Cod sursa (job #425953) | Cod sursa (job #2653039) | Cod sursa (job #237662) | Cod sursa (job #2371501) | Cod sursa (job #530800)
Cod sursa(job #530800)
var a,v:array[0..15000] of word;
n,x,y,i,j,r:longint;
m,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);
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.