记录编号 1799 评测结果 AAAAAAAAAA
题目名称 渡轮问题 最终得分 100
用户昵称 GravatarOo湼鞶oO 是否通过 通过
代码语言 Pascal 运行时间 10.000 s
提交时间 2008-09-08 19:49:56 内存使用 0.00 MiB
显示代码纯文本
{*******************************************}
{* Program Name: Maxxl                     *}
{* Input File: maxxl.in                    *}
{* Output File: maxxl.out                  *}
{* Date: 2008.7.24                         *}
{* Programmer: Peng Bo                     *}
{*******************************************}
program maxxl;
type
  jl=record
    x,y,z:word;
    end;
  sz=array[0..10000]of jl;
var
  s:sz;
  n,g:word;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure input;
var
  f:text;
  i:word;
begin
  assign(f,'maxxl.in');
  reset(f);
  readln(f,n);
  for i:=1 to n do
  begin
    readln(f,s[i].x);
    s[i].y:=1;
    s[i].z:=0;
  end;
  close(f);
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure output;
var
  f:text;
begin
  assign(f,'maxxl.out');
  rewrite(f);
  writeln(f,s[g].y);
  while g<>0 do
  begin
    write(f,s[g].x);
    g:=s[g].z;
    if g<>0
    then
      write(f,' ');
  end;
  close(f);
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure main;
var
  j,k,m:word;
begin
  for j:=(n-1) downto 1 do
  begin
    m:=0;
    for k:=(j+1) to n do
      if (s[k].x>=s[j].x)and(s[k].y>m)
      then
      begin
        m:=s[k].y;
        s[j].z:=k;
      end;
    if (m<>0)or(s[j].y>m)
    then
    begin
      s[j].y:=m+s[j].y;
      if s[j].y>=s[g].y
      then
        g:=j;
    end;
  end;
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
begin
  input;
  g:=n;
  main;
  output;
end.