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的要求,那么最好采用那些复杂性最小的要求. 让 ...
随机推荐
- node通过http.request向其他服务器上传文件
function upload(callback) { let boundaryKey = '----' + new Date().getTime(); // 用于标识请求数据段 let option ...
- eclipse打断点的调试
对于程序员来说,最重要的技能之一其实是在发现问题的时候,定位问题,然后才能解决问题. 发现问题的能力十分的重要.而debug的水平就是基础. 打断点之后,操作相应的步骤,然后eclipse会跳转到相应 ...
- HTTP-从输入url到请求回数据发生了什么
- 算法相关——Java排序算法之快速排序(三)
0. 前言 本系列文章将介绍一些常用的排序算法.排序是一个非常常见的应用场景,也是开发岗位面试必问的一道面试题,有人说,如果一个企业招聘开发人员的题目中没有排序算法题,那说明这个企业不是一个" ...
- 2-SAT超入门讲解
Preface 说实话2-SAT的题目我都没怎么做过,所以这里讲的都是些超入门什么的 还有一些板子题,由于是暑假的时候学的所以有些我也记不清了 主要学习参考自:Mancher的课件&& ...
- EZ 2018 05 20 NOIP2018 模拟赛(十五)
这次的比赛充满着玄学的气息,玄学链接 首先讲一下为什么没有第十四场 其实今天早上9点时看到题目就叫了:原题! 没错,整套试卷都做过,我还写了题解 然后老叶就说换一套,但如果仅仅是这样就没什么 但等13 ...
- TensorFlow入门(五)多层 LSTM 通俗易懂版
欢迎转载,但请务必注明原文出处及作者信息. @author: huangyongye @creat_date: 2017-03-09 前言: 根据我本人学习 TensorFlow 实现 LSTM 的经 ...
- 时间复杂度O(n^2)和O(nlog n)差距有多大?
0. 时间复杂度 接触到算法的小伙伴们都会知道时间复杂度(Time Complexity)的概念,这里先放出(渐进)时间复杂度的定义: 假设问题规模是\(n\),算法中基本操作重复执行的次数是\(n\ ...
- list 的 增 删
增: 1. name = [] 2. name.append() 3. name.extend(name2) name2为可迭代的 name + name2 与之效果一样,合并为一个列表 4. nam ...
- 如何解决jersey框架中以json格式返回数组,当数组中元素一个时json格式不对
原文地址:http://www.cnblogs.com/swpk/p/3566536.html?utm_source=tuicool jersey 是oracle 出的一个较好的REST框架.使用此框 ...