George and Round

George and Round
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers1 through m. George estimates the i-th problem's complexity by integer bi.

To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem with complexity exactly a1, at least one with complexity exactly a2, ..., and at least one with complexity exactly an. Of course, the round can also have problems with other complexities.

George has a poor imagination. It's easier for him to make some already prepared problem simpler than to come up with a new one and prepare it. George is magnificent at simplifying problems. He can simplify any already prepared problem with complexity c to any positive integer complexity d (c ≥ d), by changing limits on the input data.

However, nothing is so simple. George understood that even if he simplifies some problems, he can run out of problems for a goodround. That's why he decided to find out the minimum number of problems he needs to come up with in addition to the m he's prepared in order to make a good round. Note that George can come up with a new problem of any complexity.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 < a2 < ... < an ≤ 106) — the requirements for the complexity of the problems in a good round. The third line contains space-separated integers b1, b2, ..., bm (1 ≤ b1 ≤ b2... ≤ bm ≤ 106) — the complexities of the problems prepared by George.

Output

Print a single integer — the answer to the problem.

Sample test(s)
input
3 5
1 2 3
1 2 2 3 3
output
0
input
3 5
1 2 3
1 1 1 1 1
output
2
input
3 1
2 3 4
1
output
3
Note

In the first sample the set of the prepared problems meets the requirements for a good round.

In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.

In the third sample it is very easy to get a good round if come up with and prepare extra problems with complexities: 2, 3, 4.



我的理解是:
 他原来出了M各题,并且给出了复杂度,用数组b表示,后来有n个复杂度,用数组a表示,a b 不一样,但要求a中复杂度的题目至少有一个,所以要比较a和b,a中有的b中没有的就再加一个新题目,求的是加的最少题目数
可是啊,交上去错误了,难道理解错了???
#include <stdio.h>
#include <string.h>

int main()
{
    int n,m,a[3009],b[30009];
    int i,j,k;

    while(~scanf("%d%d",&n,&m))
    {
        k = 0;
        for(i = 0; i<n; i++)
            scanf("%d",&a[i]);
        for(i = 0; i<m; i++)
            scanf("%d",&b[i]);
        for(i = 0;i<n;i++)
        {
            for(j = 0;j<m;j++)
            {
                if(a[i] == b[j])
                    break;
            }
            if(j>=m)
                k++;
        }
        printf("%d\n",k);
    }
    return 0;
}

表示以上代码错误,以下是修改的:
#include <stdio.h>
#include <string.h>

int main()
{
    int n,m,a[3009],b[30009];
    int i,j,k;

    while(~scanf("%d%d",&n,&m))
    {
        k = 0;
        for(i = 0; i<n; i++)
            scanf("%d",&a[i]);
        for(i = 0; i<m; i++)
            scanf("%d",&b[i]);
            j = 0;
        for(i = 0;i<n;i++)
        {
            for(;j<m;j++)
            {
                if(a[i] <= b[j])
                    break;
            }
            if(j >= m)
                break;
        }
        printf("%d\n",n - i);
    }
    return 0;
}





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值