比赛 暑假培训七 评测结果 AAWAWWWWWW
题目名称 渡轮问题 最终得分 30
用户昵称 elysian 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-07-24 17:29:49
显示代码纯文本
program cc;
var
f,ff,ans,qianqu:array[1..10000] of longint;

i,j,n,max,num:longint;
fin,fout:text;
begin
assign(fin,'maxxl.in');
reset(fin);
assign(fout,'maxxl.out');
rewrite(fout);
readln(fin,n);
for i:=1 to n do
readln(fin,f[i]);
max:=0;
for i:=1 to n do ff[i]:=1;

for i:=2 to n do
for j:=1 to i-1 do
if (f[j]<f[i])and(ff[j]>=ff[i]-1) then
begin
ff[i]:=ff[j]+1;
qianqu[i]:=j;
end;
for i:=1 to n do if ff[i]>max then
begin  max:=ff[i];num:=i;end;
writeln(fout,max);
i:=0;
j:=0;

repeat
inc(i);
ans[i]:=f[num];
num:=qianqu[num];
inc(j);
until j>max-1;
for j:=i downto 2 do
write(fout,ans[j],' ');
write(fout,ans[1]);
close(fin);
close(fout);

end.