Codeforces Round #227 (Div. 2)B. George and Round
2014-01-31 12:03
387 查看
B. George and Round
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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.
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.
Sample test(s)
input
output
input
output
input
output
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.
解题报告:
此题就是找有多少个复杂工作。代码如下:
#include<stdio.h>
#include<string.h>
int n[3010],m[3010];
int main(){
int t,t1;
int i,j;
scanf("%d%d",&t,&t1);
for(i=0;i<t;i++)
scanf("%d",&n[i]);
for(i=0;i<t1;i++)
scanf("%d",&m[i]);
for(i=0,j=0;i<t&&j<t1;j++)
if(m[j]>=n[i])
i++;
printf("%d\n",t-i);
return 0;
}
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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.
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.
Sample test(s)
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.
解题报告:
此题就是找有多少个复杂工作。代码如下:
#include<stdio.h>
#include<string.h>
int n[3010],m[3010];
int main(){
int t,t1;
int i,j;
scanf("%d%d",&t,&t1);
for(i=0;i<t;i++)
scanf("%d",&n[i]);
for(i=0;i<t1;i++)
scanf("%d",&m[i]);
for(i=0,j=0;i<t&&j<t1;j++)
if(m[j]>=n[i])
i++;
printf("%d\n",t-i);
return 0;
}
相关文章推荐
- Codeforces Round #227 (Div. 2) E. George and Cards set内二分+树状数组
- Codeforces Round #267 (Div. 2) C. George and Job DP
- Codeforces Round #267 (Div. 2) C. George and Job
- Codeforces Round #267 (Div. 2) C. George and Job
- Codeforces Round #227 (Div. 2) E. George and Cards 线段树+set
- Codeforces Round #190 (Div. 2)-C. Ciel and Robot
- ICM Technex 2017 and Codeforces Round #400 (Div. 1 + Div. 2, combined) C. Molly's Chemicals
- Codeforces Round #419 (Div. 2) E. Karen and Supermarket(树形DP)
- Codeforces Round #378 (Div. 2)A. Grasshopper And the String
- Codeforces Round #312 (Div. 2) B. Amr and The Large Array
- Codeforces Round #305 (Div. 1) B. Mike and Feet(单调栈)
- 【Codeforces Round 299 (Div 2)D】【KMP 本质是最前与最后匹配】Tavas and Malekas 长度为n的匹配串被模板串多位点覆盖的匹配串个数
- ICM Technex 2017 and Codeforces Round #400 (Div. 1 + Div. 2, combined) E. The Holmes Children
- Codeforces Round #292 (Div. 2)D. Drazil and Tiles
- Codeforces Round #263 Div.1 B Appleman and Tree --树形DP【转】
- Codeforces Round #390 (Div. 2) D. Fedor and coupons
- Codeforces Round #410 (Div. 2)B. Mike and strings(暴力)
- Codeforces Round #394 (Div. 2) E. Dasha and Puzzle(分形)
- Codeforces Round #370 (Div. 2) D. Memory and Scores(DP)
- Codeforces Round #293 (Div. 2) A. Vitaly and Strings(思路)