Pagini recente » Cod sursa (job #1595066) | 3_iulie | Cod sursa (job #177850) | Cod sursa (job #2487629) | Cod sursa (job #1199247)
type tabel=array[1..1000000]of longint;
var t,max,poz:tabel;
i,j,k,m,n:longint;
begin
assign(input,'scmax.in');
reset(input);
readln(n) ;
for i:=1 to n do read(t[i]) ;
close(input);
max[1]:=1;
m:=1;
for i:=2 to n do
begin
for j:=1 to i-1 do
begin
if (t[j]<t[i])and(max[j]=m) then
begin
m:=m+1;
max[i]:=m;
end;
end;
end;
assign(output,'scmax.out');
rewrite(output);
writeln(m);
for i:=1 to n do
if max[i]<>0 then write(t[i],' ');
close(output);
end.