Pagini recente » Cod sursa (job #1886139) | Cod sursa (job #384986) | Cod sursa (job #2219895) | Cod sursa (job #2081028) | Cod sursa (job #1199250)
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
if max[j]+1>max[i]then max[i]:=max[j]+1;
m:=m+1;
end
end;
end;
assign(output,'scmax.out');
rewrite(output);
writeln(m);
if m=1 then write(t[1])else
for i:=1 to n do if max[i]<>0 then write(t[i],' ');
close(output);
end.