Cod sursa(job #344255)

Utilizator andrey932Andrei andrey932 Data 29 august 2009 14:23:20
Problema Operatii Scor 10
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.36 kb
var t:text;
    n,n2,s,max,i:longint;


begin
assign(t,'operatii.in'); reset(t);
readln(t,n);
max:=0;
for i:=1 to n do
  begin
    read(t,n2);
    if (n2=0) then
      begin
        s:=s+max;
        max:=0;
      end
    else
      if n2>max then max:=n2;
  end;
s:=s+max;
close(t);
assign(t,'operatii.out'); rewrite(t); write(t,s); close(t);
end.