codeforces387B
George and Round
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
3 5
1 2 3
1 2 2 3 3
0
3 5
1 2 3
1 1 1 1 1
2
3 1
2 3 4
1
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的更多相关文章
- 题解 【Codeforces387B】George and Round
以下选自官方题解: 考虑困难的需求数量,我们将覆盖这些困难, 然后我们将提出新的问题,并准备新的问题来覆盖其他需求. 很明显,如果我们决定满足从n中抽取i的要求,那么最好采用那些复杂性最小的要求. 让 ...
随机推荐
- spring HibernateTemplate.save() 方法的自动提交问题
如题: service1: dao1.save(obj); //失败,应该给spring捕获,但没有,程序继续执行下去了. redisService.fun1(); //被执行 service2 ...
- Multiple Threads reading from the same file(转载)
问 I have a xml file that needs to be read from many many times. I am trying to use the Parallel.ForE ...
- UOJ67 新年的毒瘤 tarjan
题目传送门 题意:给出一个$N$个点.$M$条边的无向图,找出其中的点,满足去掉该点与和它相连的边之后,这个图会变成一棵树.$N , M \leq 10^5$ 说是毒瘤,真的不毒瘤 思考一下,我们需要 ...
- 搭建Zookeepeer源码工程
一.搭建ant环境 1.下载ant&将ant解压至安装目录 http://ant.apache.org/bindownload.cgi 2.配置环境变量 ANT_HOME:配置ant的安装目录 ...
- React 等框架使用 index 做 key 的问题
React 等框架使用 index 做 key 的问题 假如有两个树,一个是之前,一个是更变之后,我们抽象成两种可能性. 插入内容在最后 插入内容在最前 关于插在中间,原理一样,就不阐述. 使用 ul ...
- sudo 与输出重定向
本文介绍如何使用 sudo 将输出重定向到当前用户没有权限的文件.注意:本文中 demo 的演示环境为 ubuntu 18.04. Permission denied 问题 如果当前用户没有某个文件的 ...
- Heartbeat基础知识-运维小结
在日常的集群系统架构中,一般用到Heartbeat的主要就2种:1)高可用(High Availability)HA集群, 使用Heartbeat实现,也称为”双机热备”, “双机互备”, “双机”: ...
- linux第二次读书笔记
<Linux内核设计与实现>读书笔记 第五章 系统调用 第五章系统调用 系统调用是用户进程与内核进行交互的接口.为了保护系统稳定可靠,避免应用程序恣意忘形. 5.1与内核通信 系统调用 ...
- github链接与心得体会
https://github.com/wangyuefang/test 第一次使用github,我觉得github是一个非常人性化的软件,使用起来很方便.而且可以把GitHub作为免费的远程仓库,如果 ...
- OSGB数据压缩
OSGB数据输出时压缩数据大小,采用如下设置 osgDB::writeNodeFile(*osgbNode, "xxx/xxxx.osgb", new osgDB::Options ...