CF387B.George and Round

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 b__i.

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 _a_1, at least one with complexity exactly _a_2, ..., and at least one with complexity exactly a__n. 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.

乔治决定筹备一场 Codesecrof 编程竞赛,为此他已准备了 mm 道题目。我们将这些题目编号为 11 至 mm。乔治用整数 bib_i 来估计第 ii 道题目的难度。

为了使这场竞赛成为一场“优质”竞赛,他至少需要在赛题集中放入 nn 道题目;此外,他还必须至少包含一道难度恰好为 a1a_1 的题目、一道难度恰好为 a2a_2 的题目,……,以及一道难度恰好为 ana_n 的题目。当然,赛题集也可以包含其他难度的题目。

乔治的想象力欠佳。对他而言,将一道已准备好的题目降低难度,远比构思一道全新题目并完成其准备工作要容易得多。而乔治在降低题目难度方面极为出色:他可以将任意一道已准备好的、当前难度为 cc 的题目,简化为任意正整数难度 dd(满足 c≥dc \ge d),方法是调整输入数据的限制条件。

然而,事情并非如此简单。乔治意识到:即使他简化了一些题目,仍可能因题目数量不足而无法组成一场“优质”竞赛。因此,他决定找出:除了已准备的 mm 道题目外,他至少还需额外构思多少道新题目,才能确保能组织出一场“优质”竞赛?注意,乔治可以构思出任意难度的新题目。

输入格式

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 _a_1, _a_2, ..., a__n (1 ≤ _a_1 < _a_2 < ... < a__n ≤ 106) — the requirements for the complexity of the problems in a good round. The third line contains space-separated integers _b_1, _b_2, ..., b__m (1 ≤ _b_1 ≤ _b_2... ≤ b__m ≤ 106) — the complexities of the problems prepared by George.

第一行包含两个整数 nn 和 mm(1≤n,m≤30001 \leq n, m \leq 3000)—— 分别表示一个“优质题组”所需的最少题目数量,以及乔治已准备的题目数量。
第二行包含 nn 个用空格分隔的整数 a1, a2, …, ana_1,\ a_2,\ \dots,\ a_n(1≤a1<a2<⋯<an≤1061 \leq a_1 < a_2 < \dots < a_n \leq 10^6)—— 表示一个“优质题组”对各题目难度的要求。
第三行包含 mm 个用空格分隔的整数 b1, b2, …, bmb_1,\ b_2,\ \dots,\ b_m(1≤b1≤b2≤⋯≤bm≤1061 \leq b_1 \leq b_2 \leq \dots \leq b_m \leq 10^6)—— 表示乔治所准备题目的难度。

输出格式

Print a single integer — the answer to the problem.

输出一个整数——该问题的答案。

输入输出样例

  • 输入#1

    3 5
    1 2 3
    1 2 2 3 3

    输出#1

    0
  • 输入#2

    3 5
    1 2 3
    1 1 1 1 1

    输出#2

    2
  • 输入#3

    3 1
    2 3 4
    1

    输出#3

    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.

在第一个样例中,已准备的题目集合满足优质赛制的要求。

在第二个样例中,只需构思并准备两道难度分别为 2 和 3 的题目,即可构成一场优质赛制。

在第三个样例中,只需额外构思并准备难度分别为 2、3、4 的题目,便极易构成一场优质赛制。

输入解题思路,AI测评打分。不知道怎么写?

首页