Cod sursa(job #251049)

Utilizator valytgjiu91stancu vlad valytgjiu91 Data 1 februarie 2009 18:32:29
Problema Datorii Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.45 kb
var f,g:text;
c,v:array[1..15000] of longint;
n,m,i,j,x,s,y,p:longint;
begin
assign(f,'datorii.in');
reset(f);
assign(g,'datorii.out');
rewrite(g);
readln(f,n,m);
for i:=1 to n do
begin
read(f,v[i]);
c[i]:=c[i-1]+v[i];
end;

for i:=1 to m do
begin
  readln(f,p,x,y);
  if p=1 then
       begin
         s:=c[y]-c[x-1];
         writeln(g,s);
         end
         else for j:=x to n do
               c[j]:=c[j]-y;
end;
close(g);
end.