Pagini recente » Cod sursa (job #856394) | Cod sursa (job #2978871) | Cod sursa (job #1075606) | Cod sursa (job #2349803) | Cod sursa (job #1161139)
program datorii;
var a:array[0..120000] of longint;
b1,b2:array[1..1 shl 16] of char;
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);
settextbuf(input,b1);
assign(output,'datorii.out'); rewrite(output);
settextbuf(output,b2);
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.