Cod sursa(job #528392)

Utilizator gicu_01porcescu gicu gicu_01 Data 2 februarie 2011 18:46:17
Problema Datorii Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.55 kb
var a:array[1..15000]of int64;
    b:array[1..15000]of int64;
    n,m,i,j:longint;z,x,y,p,c,k:int64; f,t:text;
begin
 assign(f,'datorii.in');
 reset(f);
 assign(t,'datorii.out');
 rewrite(t);
 readln(f,n,m);
 k:=0;
 for i:=1 to n do begin read(f,c); k:=k+c; a[i]:=k; b[i]:=0; end;
 readln(f);
 for i:=1 to m do
  begin
   readln(f,x,y,z);
   if x=0 then b[y]:=b[y]+z else
    if x=1 then
     begin
      p:=0;
      for j:=y to z do p:=p+b[j];
      k:=a[z]-a[y-1]-p;
      writeln(t,k);
     end;
  end;
 close(f);
 close(t);
end.