记录编号 54119 评测结果 AAAAA
题目名称 [NOIP 1999]拦截导弹 最终得分 100
用户昵称 GravatarCAX_CPG 是否通过 通过
代码语言 Pascal 运行时间 0.001 s
提交时间 2013-03-08 15:49:05 内存使用 0.18 MiB
显示代码纯文本
var a,d,f,h:array[1..1000]of longint;
    i,j,tot,l,r,n,mid,lis:longint;

begin
 assign(input,'missile.in');reset(input);
 assign(output,'missile.out');rewrite(output);
 while not seekeof do
  begin inc(n);read(a[n]);end;
 for i:=n downto 1 do
  begin
   l:=1;r:=lis;
   while l<=r do
    begin
     mid:=(l+r)shr 1;
     if d[mid]<=a[i]then l:=mid+1 else r:=mid-1;
    end;
   dec(l);
   if l+1>lis then lis:=l+1;
   f[i]:=l+1;
   if (a[i]<d[f[i]])or(d[f[i]]=0)then d[f[i]]:=a[i];
  end;
 writeln(lis);
 for i:=1 to n do
  begin
   l:=0;
   for j:=1 to tot do
    if h[j]>=a[i]then begin h[j]:=a[i];l:=1;break;end;
   if l=0 then begin inc(tot);h[tot]:=a[i];end;
  end;
 writeln(tot);
 close(input);close(output);
end.