B. George and Round
来源:互联网 发布:阿里云蜘蛛池全破解版 编辑:程序博客网 时间:2024/06/04 23:26
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.
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.
Print a single integer — the answer to the problem.
3 51 2 31 2 2 3 3
0
3 51 2 31 1 1 1 1
2
3 12 3 41
3
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.
解题说明:题目的意思其实就是判断第二行数字是否被包含在第三行数字之中,或者是第三行数字比第二行数字大也行。由于数字已经按照从小到大排序,可以通过遍历来判断对应第三行数字是否都大于等于第二行数字,统计出不满足条件的情况,求和即可。
#include<iostream>#include<cstdio>#include<cmath>#include<cstdlib>#include <algorithm>#include<cstring>using namespace std;int b[3001], a[3001];int main(){int n, m, j, i, sum = 0;scanf("%d%d", &n, &m);for (i = 0; i < n; i++){scanf("%d", &a[i]);}for (i = 0; i < m; i++){scanf("%d", &b[i]);}for (i = 0, j = 0; i<n&&j<m; j++){if (b[j] >= a[i]){i++;}}printf("%d\n", n - i);return 0;}
- B. George and Round
- codeforces-387B. George and Round
- CodeForces 387B George and Round
- CodeForces 387B George and Round
- Codeforces 387B George and Round
- CodeForces387B B - George and Round 贪心+暴力
- George and Round CodeForces - 387B
- Codeforces Round #227 (Div. 2)B. George and Round
- Codeforces Round #227 (Div. 2) B. George and Round
- George and Round
- codeforces George and Round
- CF - 387 - B. George and Round(指针)
- Codeforces 387B George and Round(贪心)
- 【简单题】-CF-387B-George and Round
- 贪心-Code forces -387B -George and Round
- Codeforces Round #227 (Div. 2)A. George and Sleep
- Codeforces Round #227 (Div. 2)C. George and Number
- Codeforces Round #267 (Div. 2) A. George and Accommodation
- prototype javascript
- python邮件随机自动发送器
- C#高性能大容量SOCKET并发(五):粘包、分包、解包
- 十个应该知道的正则表达式例子
- 做了个隐藏进程跟保护进程的小工具
- B. George and Round
- Android瀑布流照片墙实现,体验不规则排列的美感
- 《略说USB Key》之前言概述
- 关于SSDT HOOK取消内存写保护的问题
- android获取屏幕控件位置问题
- .NET Framwork,C#入门开发教程,零基础必看
- 常用 HTML 头部标签
- C#高性能大容量SOCKET并发(八):通讯协议
- 由tr命令想到的