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 mhe'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.

Examples

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.

sol:注意到n很小,n2都可以过,于是直接暴力模拟。

我猜应该有O(n*logn)的做法,比方说开一个multiset,先排遍序,每次取大于等于当前这个数的第一个,然后弹掉(这只是嘴巴,我没写过)

#include <bits/stdc++.h>
using namespace std;
typedef int ll;
inline ll read()
{
ll s=;
bool f=;
char ch=' ';
while(!isdigit(ch))
{
f|=(ch=='-'); ch=getchar();
}
while(isdigit(ch))
{
s=(s<<)+(s<<)+(ch^); ch=getchar();
}
return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
if(x<)
{
putchar('-'); x=-x;
}
if(x<)
{
putchar(x+''); return;
}
write(x/);
putchar((x%)+'');
return;
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
const int N=;
int n,m,a[N],b[N];
bool Bo[N];
int main()
{
int i,j,ans;
R(n); R(m);
ans=n;
for(i=;i<=n;i++) R(a[i]);
for(i=;i<=m;i++) R(b[i]);
sort(b+,b+m+);
for(i=;i<=n;i++)
{
for(j=;j<=m;j++) if(b[j]>=a[i]&&(!Bo[j]))
{
Bo[j]=; ans--; break;
}
}
Wl(ans);
return ;
}

codeforces387B的更多相关文章

  1. 题解 【Codeforces387B】George and Round

    以下选自官方题解: 考虑困难的需求数量,我们将覆盖这些困难, 然后我们将提出新的问题,并准备新的问题来覆盖其他需求. 很明显,如果我们决定满足从n中抽取i的要求,那么最好采用那些复杂性最小的要求. 让 ...

随机推荐

  1. PAT A1014 Waiting in Line (30 分)——队列

    Suppose a bank has N windows open for service. There is a yellow line in front of the windows which ...

  2. #ifdef __cplusplus extern "C" { #endif”的定义

      平时我们在linux c平台开发的时候,引用了一些Cpp或者C的代码库,发现一些头文件有如下代码条件编译. #ifdef __cplusplus extern "C" { #e ...

  3. Kubernetes 1.10.4 镜像 版本

    1. gcr.io/google-containers/hyperkube:1.10.4 gcr.io/google_containers/pause-amd64:3.0 gcr.io/google_ ...

  4. bat无故报错打印混乱的解决

    1. 下面语句加了一个无意义的ping操作.不加的时候经常报错,报操作数不是数字,实际上打印发现NOW值和格式并没有错误.怀疑是下面操作数太多了,而执行速度又太快,导致执行时总是很容易出错.通过增加一 ...

  5. Android自动化测试之:获取 参数:comonentName 的值方法

    十年河东十年河西,莫欺少年穷! 不了解Activity的,可参考:http://www.cnblogs.com/tekkaman/archive/2011/06/07/2074211.html 相关代 ...

  6. [Oracle]ORA-600[kdBlkCheckError]LOB坏块处理

    [Oracle]ORA-600[kdBlkCheckError]LOB坏块处理 客户环境报如下错误: ORA - 00600: Internal error code, arguments: [kdB ...

  7. LOJ #6074. 「2017 山东一轮集训 Day6」子序列

    #6074. 「2017 山东一轮集训 Day6」子序列 链接 分析: 首先设f[i][j]为到第i个点,结尾字符是j的方案数,这个j一定是从i往前走,第一个出现的j,因为这个j可以代替掉前面所有j. ...

  8. Vue 实际项目中你可能会遇见问题

    纸上得来终觉浅,绝知此事要躬行! Vue的文档和教程看的太多,小的demo做的多,也不如自己实际的进行一个完整项目的开发.只有做了才知道原来问题这么多,这里列举了一些你做demo教程可能不会遇见的坑. ...

  9. 【亲测有效】Centos安装完成docker后启动docker报错docker: unrecognized service的两种解决方案

    今天在学习Docker的时候 使用yum install docker安装完后启动不了,报错如下: [root@Sakura ~]# service docker start docker: unre ...

  10. Ubuntu16.04下使用rdesktop命令远程连接windows机器

    前段时间在本机安装了ubuntu16.04桌面版,后来需要远程连接一台win10系统的跳转机,下面介绍使用rdesktop命令远程连接windows机器的操作记录:1)首先安装rdesktop工具 k ...