Pagini recente » Cod sursa (job #431273) | Cod sursa (job #2253818) | Cod sursa (job #2240094) | Cod sursa (job #1340529) | Cod sursa (job #1344315)
var n,i,j,k:longint;
a,b:array[0..100000] of longint;
procedure bin(s:string);
var i:longint; r:boolean;
begin
if length(s)=n then begin
r:=true;
for i:=1 to n-1 do
if s[i]='0' then
if a[i]>=a[i+1] then r:=false;
if r and (k>j) then begin
j:=0;
for i:=1 to n do
if s[i]='0' then begin
inc(j);
b[j]:=a[i];
end;
end;
end else begin
inc(k);
bin(s+'0');
dec(k);
bin(s+'1');
end;
end;
begin
assign(input,'scmax.in');
assign(output,'scmax.out');
reset(input);
rewrite(output);
read(n);
for i:=1 to n do read(a[i]);
j:=0;
bin('');
writeln(j);
for i:=1 to j do write(b[i],' ');
end.