No.7 2011-02-26 06:14:00
点我顶贴
收藏
删除
program vv;
type
arr=array[1..2000]of integer;
var
a,n,m,b,i,k:integer;
t,p:arr;
procedure qsort(lx,rx:integer;s:arr);
var
i,j,t,l:integer;
begin
i:=lx;j:=rx;t:=s[I];
repeat
while (s[j]>t) and (j>I) do
begin
k:=k+1;
j:=j-1
end;
if I<j then
begin
s[I]:=s[j];I:=I+1;l:=l+1;
while (s[I]<t) and (I<j) do
begin
k:=k+1;
i:=I+1
end;
if I<j then
begin
s[j]:=s[I];j:=j-1;l:=l+1;
end;
end;
until I=j;
s[I]:=t;I:=I+1;j:=j-1;l:=l+1;
if lx<j then qsort(lx,j,s);
if I<rx then qsort(I,rx,s)
end;
begin
readln(n,m);
for a:=1 to n do readln(p[a]);
for a:=1 to m do readln(t[a]);
qsort(1,1,t);
qsort(1,1,p);
for a:=1 to n do
for b:=1 to m do
if (p[a]>=t[b])and(t[b]<>0) then begin
t[b]:=0;
inc(k);
break;
end;
writeln(n-k);
end.
问题是超时,可是我用的是快排呀。