Pagini recente » Cod sursa (job #2067558) | Cod sursa (job #1022516) | Cod sursa (job #1933193) | Cod sursa (job #964478) | Cod sursa (job #1203015)
program datorii;
type
tabel=array [0..15001] of longint;
var
t:tabel;
n,m,i,j,k,x,y,s:longint;
f1,f2:text;
begin
assign (f1,'datorii.in');
assign (f2,'datorii.out');
reset (f1);
rewrite (f2);
readln (f1,n,m);
for i:=1 to n do
read (f1,t[i]);
for i:=1 to m do begin
readln (f1,k,x,y);
s:=0;
if k=1 then begin
for j:=x to y do s:=s+t[j];
writeln (f2,s);
end else
if k=0 then begin
t[x]:=t[x]-y;
end;
end;
close (f1);
close (f2);
end.