Cod sursa(job #6270)

Utilizator marius21Petcu Marius marius21 Data 18 ianuarie 2007 17:14:41
Problema Datorii Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.43 kb
var  cod,n,m,i,j,sum,x,y:longint;
a:array[1..15000] of longint;
f,g:text;
begin
assign(f,'datorii.in');
assign(g,'datorii.out');
reset(f);
rewrite(g);
readln(f,n,m);
for i:=1 to n do read(f,a[i]);
readln(f);
for i:=1 to m do begin
read(f,cod,x,y);
if not m=i then readln(f);
if cod=0 then a[x]:=a[x]-y;
if cod=1 then begin
sum:=0;
for j:=x to y do inc(sum,a[j]);
writeln(g,sum);
end;
end;
close(f);
close(g);
end.