AC了啊

var a,b:array[1..10000]of integer;
i,j,m,t,n,sum:integer;
begin
read(n,m);
for i:=1 to n do read(a[i]); //读入两个数组

for i:=1 to m do read(b[i]);
for i:=1 to n-1 do //冒泡排序a数组
for j:=1 to n-i do
if a[j]<a[j+1] then
begin
t:=a[j]; a[j]:=a[j+1]; a[j+1]:=t;
end;
for i:=1 to n-1 do //冒泡排序b数组
for j:=1 to n-i do
if b[j]<b[j+1] then
begin
t:=b[j]; b[j]:=b[j+1]; b[j+1]:=t;
end;
sum:=0; //计数器清零
for i:=1 to n do
for j:=1 to m do
if (a[i]>b[j]) and (b[j]<>0) then //如果陶陶的高度小于不等于零苹果的高度则
begin
b[j]:=0; //清零
inc(sum);
break; //退出循环
end;
write(sum);
end.

2 条评论

  • @ 2016-11-06 18:38:24

    var
    a,b:array[0..100000] of longint;
    i,j,k,n,m,num:longint;
    begin
    readln(n,m);num:=0;
    for i:=1 to n do readln(a[i]);
    for i:=1 to m do readln(b[i]);
    for i:=1 to m-1 do
    for j:=i+1 to m do
    if b[i]<b[j] then begin
    k:=b[i];b[i]:=b[j];b[j]:=k; end;
    for i:=1 to n do
    for j:=1 to m do
    if (b[j]<>0) and (a[i]>b[j]) then begin
    inc(num); b[j]:=0; break;end;
    writeln(m-num);
    end.
    看来是同道中人

  • @ 2016-11-06 18:37:00

    wao

  • 1

信息

ID
1291
难度
6
分类
贪心 点击显示
标签
(无)
递交数
9761
已通过
2342
通过率
24%
被复制
16
上传者