Pagini recente » Cod sursa (job #944151) | Cod sursa (job #2560475) | Istoria paginii runda/255157 | Cod sursa (job #1488317) | Cod sursa (job #147994)
Cod sursa(job #147994)
program operatii;
{$APPTYPE CONSOLE}
uses
SysUtils;
var a,b,c,n,max,i,j:longint;
v:array [1..1000000] of longint;
fin,fout:text;
{*------------------------*}
procedure citire;
begin
assign(fin,'operatii.in'); reset(fin);
assign(fout,'operatii.out'); rewrite(fout);
readln(fin,n);
max:=-1;
for i:=1 to n do
begin
read(fin,v[i]);
if max < v[i] then max:=v[i];
end;
close(fin);
end;
{*------------------------*}
function cauta:integer;
begin
max:=0;
cauta:=0;
for i:=a to b do
if v[i] > max then
begin
max:=v[i];
end;
cauta:=max;
end;
{*----------MAIN----------*}
begin
citire;
//inc(max);
c:=0;
j:=0;
while j<n do
begin
inc(j);
a:=j;
while ((v[j]<>0) and (j < n)) do inc(j);
b:=j;
c:=c+cauta;
end;
writeln(fout,c);
close(fout);
end.