Pagini recente » Cod sursa (job #170217) | Cod sursa (job #157174) | Cod sursa (job #3143414) | Cod sursa (job #1021764) | Cod sursa (job #175881)
Cod sursa(job #175881)
var f,g:text;
a:array[0..100001] of longint;
n,max,dub,i,start,fin,s,sf:longint;
begin
assign(f,'scmax.in'); reset(f);
assign(g,'scmax.out'); rewrite(g);
readln(f,n);
a[0]:=maxlongint;
max:=0;
start:=1; sf:=1;
dub:=0;
read(f,a[1]);
for i := 2 to n do begin
read(f,a[i]);
if a[i-1]<a[i] then begin
inc(sf);
end;
{else}
if a[i-1]=a[i] then begin
inc(sf);
inc(dub);
end;
{else}
if a[i-1]>a[i] then begin
if max <= (sf-start+1)-dub then begin
max:=sf-start+1 - dub;
s:=start;
fin:=sf;
end;
start:=i; sf:=i; dub:=0;
end;
if n=i then begin
if max <= (sf-start)-dub then begin
max:=sf-start+1 - dub;
s:=start;
fin:=sf;
dub:=0;
end;
end;
end;
writeln(g,max);
for i := s to fin do begin
if (i<>s) then begin
if a[i]<>a[i-1] then write(g,a[i],' ');
end else
write(g,a[i],' ');
end;
close(f);
close(g);
end.