Cod sursa(job #171686)

Utilizator noi_marinescuotilia marinescu noi_marinescu Data 4 aprilie 2008 20:01:35
Problema Operatii Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.45 kb
var   f,g:text; n,i,j,k:0..1000000; max:int64; poz, v:array[1..1000000] of 1..100000;
s:longint;
begin
assign(f,'operatii.in');
reset(f);
assign(g,'operatii.out');
rewrite(g);
readln(f,n);
for i:=1 to n do read(f,v[i]);
max:=0;
for i:=1 to n do if v[i]>max then max:=v[i];
k:=0;   s:=0;
for i:=1 to n do
if v[i]=max then begin k:=k+1; poz[i]:=i; end;
for j:=1 to k-1 do   if poz[j]-poz[j+1]<>1 then s:=s+max;
write(g,s);
close(g); close(f);  end.