贪心-Code forces -387B -George and Round

Code forces -387B -George and Round

 

description

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 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 Input

3 5

1 2 3

1 2 2 3 3

 

3 5

1 2 3

1 1 1 1 1

 

3 1

2 3 4

1

Sample Output

0

2

3

大意:乔治要为比赛命题,共n道,每道题的复杂度给出。他自己已经准备好了m道题,复杂度也给出。若命题的复杂度不低于要求的复杂度,则认为此题合格。

问:乔治尽可能多的用自己的题,那么他最少还得出几道新题?

分析:尽量多用已有的题,就要求对自己的题按复杂度由低到高排序,从头到尾遍历,若能用则用(贪心)。对要求的题也排序是为了便于比较。

 

时间: 2024-09-13 23:23:22

贪心-Code forces -387B -George and Round的相关文章

Code forces 103A---Testing Pants for Sadness

点击打开链接 A. Testing Pants for Sadness time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The average miner Vaganych took refresher courses. As soon as a miner completes the courses, he should t

Code forces 200C---Football Championship

点击打开链接 题目: C. Football Championship time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Any resemblance to any real championship and sport is accidental. The Berland National team takes part i

jsp在线考试系统-htm文件

js|在线 一个在线考试系统,测试你的jsp知识,代码不是特别多,所以不加注释了(http://jspbbs.yeah.net) index.jsp <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"> <TR> <TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sa

Zend Framework教程之响应对象的封装Zend_Controller_Response实例详解_php实例

本文实例讲述了Zend Framework教程之响应对象的封装Zend_Controller_Response用法.分享给大家供大家参考,具体如下: 概述 响应对象逻辑上是请求对象的搭档.目的在于收集消息体和/或消息头,因而可能返回大批的结果. Zend_Controller_Response响应对象的基本实现 ├── Response │   ├── Abstract.php │   ├── Cli.php │   ├── Exception.php │   ├── Http.php │  

GCJ 2008 Round 1AA Minimum Scalar Product:贪心

http://code.google.com/codejam/contest/32016/dashboard Problem You are given two vectors v1=(x1,x2,...,xn) and v2=(y1,y2,...,yn). The scalar product of these vectors is a single number, calculated as x1y1+x2y2+...+xnyn. Suppose you are allowed to per

Codeforces Round #205 (Div. 2) / 353C Find Maximum (贪心)

Valera has array a, consisting of n integers a0,a1,...,an-1, and function f(x), taking an integer from 0 to 2n-1 as its single argument. Value f(x) is calculated by formula , where value bit(i) equals one if the binary representation of number xconta

Code Jam 2010 Round 1A Problem C

Problem C. Number Game Problem Arya and Bran are playing a game. Initially, two positive integers A and B are written on a blackboard. The players take turns, starting with Arya. On his or her turn, a player can replace A with A - kB for any positive

Code Jam 2010 Round 1B Problem A

Problem B. Picking Up Chicks Problem A flock of chickens are running east along a straight, narrow road. Each one is running with its own constant speed. Whenever a chick catches up to the one in front of it, it has to slow down and follow at the spe

Code Jam 2010 Round 1A Problem B

Problem B. Make it Smooth Problem You have a one-dimensional array of N pixels. Each pixel has a value, represented by a number between 0 and 255, inclusive. The distance between two pixels is the absolute difference of their numbers. You can perform