q.we@@@ 2012-10-23 22:27:00
点我顶贴
收藏
删除
var a,b,o:array[0..10000]of longint;
i,j,max,n,x,y:longint;
procedure sqrt(l,r:longint);
var i,j,t,s:longint;
begin
i:=l;j:=r; s:=a[(l+r) div 2];
repeat
while a[i]<s do inc(i);
while a[j]>s do dec(j);
if i<=j then begin
t:=a[i]; a[i]:=a[j]; a[j]:=t;
t:=b[i]; b[i]:=b[j]; b[j]:=t;
inc(i);dec(j);
end;
until i>j;
if l<j then sqrt(l,j);
if i<r then sqrt(i,r);
end;
begin
readln(x,y);
while true do
begin
fillchar(o,sizeof(o),0);
if (x=0)and(y=0) then halt;
readln(n);
for i:=1 to n do readln(a[i],b[i]);
sqrt(1,n);
readln(x,y);
b[0]:=-maxlongint;
for i:=1 to n do
for j:=0 to i-1 do
if (b[j]<b[i])and(o[j]+1>o[i]) then o[i]:=o[j]+1;
max:=-maxlongint;
for i:=1 to n do
if o[i]>max then max:=o[i];
writeln(max);
end;
end.