最长上升子序列(nlog n)
呵呵
program hehe;
var
n,i,j,k,l:longint;
d,f,a:array[0..5000] of longint;
function find(l,r:longint):longint;
var
mid:longint;
begin
if l=r then exit(l);
mid:=(l+r)>>1;
if d[mid]>=a[i] then exit(find(l,mid));
exit(find(mid+1,r));
end;
begin
readln(n);
for i:=1 to n do read(a[i]);
for i:=1 to n do
begin
if a[i]>d[l] then
begin
inc(l);
d[l]:=a[i];
end
else
begin
{writeln('i=',i);
for j:=1 to l do write(d[j],' ');
writeln;
writeln(find(1,l));}
d[find(1,l)]:=a[i];
end;
end;
writeln(l);
end.