Pagini recente » Cod sursa (job #3255335) | Cod sursa (job #2755199) | Cod sursa (job #3209613) | Cod sursa (job #2459710) | Cod sursa (job #1001707)
program ab;
var n,m,i,s,j:integer;
a,b,c,d:array[1..1000] of integer;
fis,fo:text;
begin
Assign(fis, 'datorii.in');
Reset(fis);
read(fis,n);
readln(fis,m);
i:=0;
while not eoln(fis) do begin i:=i+1; read(fis,a[i]); end;
i:=0;
while not eof(fis) do
begin
i:=1+i;
read(fis,b[i]);
read(fis,c[i]);
readln(fis,d[i]);
end;
Close(fis);
Assign(fo, 'datorii.out');
Rewrite(fo);
for i:=1 to m do
begin
if(b[i]=0) then begin
a[c[i]] := a[c[i]] - d[i];
end
else
begin
s:=0;
for j:=c[i] to d[i] do s:=s+ a[j];
writeln(fo,s);
end;
end;
Close(fo);
end.