Pagini recente » Cod sursa (job #2634762) | Cod sursa (job #1538189) | Cod sursa (job #3252022) | Cod sursa (job #1691016) | Cod sursa (job #1101620)
program datorii;
var a:array[0..120000] of longint;
i,j,x,y,op,n,m:longint;
procedure update(poz,val:longint);
begin
while (poz<=n) do begin
inc(a[poz],val);
poz:=poz+(poz and(-poz));
end;
end;
function suma(poz:longint):longint;
var s:longint;
begin
s:=0;
while (poz>0) do begin
inc(s,a[poz]);
poz:=poz-(poz and (-poz));
end;
suma:=s;
end;
begin
assign(input,'datorii.in'); reset(input);
assign(output,'datorii.out'); rewrite(output);
readln(n,m);
for i:=1 to n do begin
read(x);
update(i,x);
end;
for i:=1 to m do begin
readln(op,x,y);
if op=0 then update(x,-y)
else writeln(suma(y)-suma(x-1));
end;
close(output);
end.