Pagini recente » Cod sursa (job #1349856) | Cod sursa (job #1694181) | Cod sursa (job #1628069) | Cod sursa (job #1649265) | Cod sursa (job #201516)
Cod sursa(job #201516)
program datorii_007;
var a:array[1..20000] of longint;
n,m:longint;
procedure put(i,x:longint);
begin
while i<=n do begin
inc(a[i],x);
i:=(i or (i-1)) +1;
end;
end;
function sum(i:word):longint;
var s:longint;
begin
s:=0;
while i>0 do begin
s:=s+a[i];
i:=i and (i-1);
end;
sum:=s;
end;
procedure main;
var fin,fout:text;
i,j,x,st,en,s1,s2,cod:longint;
begin
assign(fin,'datorii.in'); reset(fin);
assign(fout,'datorii.out'); rewrite(fout);
readln(fin,n,m);
for i:=1 to n do begin
read(fin,x); put(i,x);
end;
for i:=1 to m do begin
read(fin,cod);
if cod=0 then begin
read(fin,j,x);
put(j,-x);
end
else begin
read(fin,st,en);
s1:=sum(st-1); s2:=sum(en);
writeln(fout,s2-s1);
end;
end;
close(fin); close(fout);
end;
BEGIN
main;
END.