Pagini recente » Cod sursa (job #1742372) | Cod sursa (job #1180798) | Cod sursa (job #2914235) | Cod sursa (job #2304876) | Cod sursa (job #108440)
Cod sursa(job #108440)
program datorii;
var f,fout:Text;
n,m,i,t,a,b,c:longint;
v:array[0..15000] of longint;
procedure hozzaad(index,ertek:longint);
var t:longint;
begin
t:=index;
while(t<=n) do
begin
v[t]:=v[t]+ertek;
t:=t+((t xor (t-1)) and t);
end;
end;
function ossz(index:longint):longint;
var t,o:longint;
begin
o:=0;
t:=index;
while(t > 0) do
begin
o:=o+v[t];
t:=t-((t xor (t-1)) and t);
end;
ossz:=o;
end;
begin
assign(f,'datorii.in');
reset(f);
readln(f,n,m);
for i:=1 to n do
begin
read(f,t);
hozzaad(i,t);
end;
readln(f);
assign(fout,'datorii.out');
rewrite(fout);
for i:=1 to m do
begin
readln(f,a,b,c);
if(a=0) then hozzaad(b,(-1)*c)
else writeln(fout,ossz(c)-ossz(b-1));
end;
close(fout);
close(f);
end.