Cod sursa(job #320080)
| Utilizator | Data | 3 iunie 2009 15:29:26 | |
|---|---|---|---|
| Problema | Operatii | Scor | 10 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 0.91 kb |
var ok:boolean;
f:text;
n,op,x,i,max:longint;
begin
assign(f,'operatii.in');
reset(f);
readln(f,n);
ok:=false;
op:=0;
max:=0;
for i:=1 to n do begin
read(f,x);
if (x<>0) and not ok then begin
ok:=true;
max:=x;
end
else
if (x<>0) and ok then begin
if x>max then max:=x;
end
else
if x=0 then begin
ok:=false;
op:=op+max;
max:=0;
end;
end;
close(f);
op:=op+max;
assign(f,'operatii.out');
rewrite(f);
write(f,op);
close(f);
end.
