Cod sursa(job #114973)
| Utilizator | Data | 16 decembrie 2007 10:01:06 | |
|---|---|---|---|
| Problema | Operatii | Scor | 10 |
| Compilator | fpc | Status | done |
| Runda | preONI 2008, Runda 2, Clasa a 9-a | Marime | 0.53 kb |
program Operatii;
var
Fl : text;
n, i, s, a, p_max : longint;
begin
Assign(Fl,'operatii.in');
Reset(Fl);
ReadLn(Fl,n);
s := 0;
p_max := 0;
for i := 1 to n do
begin
Read(Fl,a);
if (a <> 0) and (a > p_max) then
p_max := a;
if (a = 0) or (i = n) then
begin
s := s + p_max;
p_max := 0;
end;
end;
Close(Fl);
Assign(Fl,'operatii.out');
ReWrite(Fl);
Writeln(Fl,s);
Close(Fl);
end.
