George and Round CodeForces - 387B

George and Round CodeForces - 387B

题目描述

George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let’s number the problems with integers 1 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 good round. 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.

这里写图片描述

大致题意
George 为比赛命题,共n道,每道题有一个复杂度。他自己已经准备了m道题,每道题也有个复杂度。如果命题的复杂度不低于要求的复杂度,则认为此题合格,问他最少还得出几道新题?

思路
水题,贪心,将两个数组sort从小到大排序一下,然后进行比较即可。

下面是代码

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <cmath>
#include<cstring>
using namespace std;
int main()
{
     int a[3010],b[3010],i,j,k,n,m,sum;
     cin>>n>>m;
     sum=n;
     for(i=0;i<n;i++)
     cin>>a[i];
     for(i=0;i<m;i++)
     cin>>b[i];
     sort(a,a+n);
     sort(b,b+m);
     i=0;
     j=0;
     while(i<n&&j<m)
     {
         if(a[i]<=b[j])
         {
             sum--;
             i++;
             j++;
         }
         else if(a[i]>b[j])
         j++;
     }
     cout<<sum;
     return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值