Pagini recente » Cod sursa (job #2087271) | Cod sursa (job #777557) | Cod sursa (job #2316149) | Cod sursa (job #1462395) | Cod sursa (job #567009)
Cod sursa(job #567009)
var a:array[1..15000] of 0..1000;
v:array[1..15000] of longint;
buf:array[1..15000] of integer;
cod:0..1;
n,x,y,j:0..15000;
m,s,i,r:longint;
f,t:text;
begin
assign(f,'datorii.out');
rewrite(f);
assign(t,'datorii.in');
reset(t);
readln(t,n,m);
settextbuf(f,buf);
settextbuf(t,buf);
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,cod,x,y);
case cod of
0: begin
while x<=n do
begin
v[x]:=v[x]-y;
x:=x+(x xor (x and (x-1)));
end;
end;
1: begin
s:=0;
while y>0 do
begin
s:=s+v[y];
y:=y-(y xor (y and (y-1)));
end;
x:=x-1;
r:=0;
while x>0 do
begin
r:=r+v[x];
x:=x-(x xor (x and (x-1)));
end;
writeln(f,s-r);
end;
end;
end;
close(t);
close(f);
end.