Pagini recente » Cod sursa (job #2885736) | Cod sursa (job #658899) | Cod sursa (job #171719) | Cod sursa (job #2442029) | Cod sursa (job #588464)
Cod sursa(job #588464)
var a:array[1..15000]of longint;
n,m:longint;
procedure modif(x,k:longint);
begin
while x<=n do
begin
inc(a[x],k);
inc(x,(x xor (x-1))and x);
end;
end;
function suma(x:longint):longint;
var k:longint;
begin
k:=0;
while x>0 do
begin
inc(k,a[x]);
dec(x,(x xor (x-1))and x);
end;
suma:=k;
end;
procedure calc;
var i,x,y,p:longint; f,t:text;
begin
assign(f,'datorii.in');
reset(f);
assign(t,'datorii.out');
rewrite(t);
readln(f,n,m);
for i:=1 to n do
begin
read(f,p);
modif(i,p);
end;
readln(f);
for i:=1 to m do
begin
readln(f,p,x,y);
if p=0 then modif(x,-y) else writeln(t,suma(y)-suma(x-1));
end;
close(t);
close(f);
end;
begin
calc;
end.