比赛 暑假培训七 评测结果 AAAWWAAAAA
题目名称 渡轮问题 最终得分 80
用户昵称 Oo湼鞶oO 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-07-24 17:37:31
显示代码纯文本
{*******************************************}
{* 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[1..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 2 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.