CF862A.Mahmoud and Ehab and the MEX

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Dr. Evil kidnapped Mahmoud and Ehab in the evil land because of their performance in the Evil Olympiad in Informatics (EOI). He decided to give them some problems to let them go.

Dr. Evil is interested in sets, He has a set of n integers. Dr. Evil calls a set of integers evil if the MEX of it is exactly x. the MEX of a set of integers is the minimum non-negative integer that doesn't exist in it. For example, the MEX of the set {0, 2, 4} is 1 and the MEX of the set {1, 2, 3} is 0 .

Dr. Evil is going to make his set evil. To do this he can perform some operations. During each operation he can add some non-negative integer to his set or erase some element from it. What is the minimal number of operations Dr. Evil has to perform to make his set evil?

邪恶博士因马哈茂德和埃哈卜在邪恶信息学奥林匹克竞赛(EOI)中的表现,将他们绑架到了邪恶之地。他决定给他们一些问题,答对后才放他们离开。

邪恶博士对集合很感兴趣,他拥有一个包含 nn 个整数的集合。邪恶博士称一个整数集合为“邪恶集合”,当且仅当该集合的 MEX 恰好等于 xx。一个整数集合的 MEX(minimum excluded value,最小缺失非负整数)是指不在该集合中的最小非负整数。例如,集合 {0, 2, 4}\{0, 2, 4\} 的 MEX 是 11,而集合 {1, 2, 3}\{1, 2, 3\} 的 MEX 是 00。

邪恶博士打算将他当前的集合改造成一个“邪恶集合”。为此,他可以执行若干次操作:每次操作中,他可以向集合中添加某个非负整数,或从集合中删除某个元素。那么,邪恶博士至少需要执行多少次操作,才能使他的集合变为邪恶集合?

输入格式

The first line contains two integers n and x (1 ≤ n ≤ 100, 0 ≤ x ≤ 100) — the size of the set Dr. Evil owns, and the desired MEX.

The second line contains n distinct non-negative integers not exceeding 100 that represent the set.

第一行包含两个整数 nn 和 xx(1≤n≤1001 \leq n \leq 100,0≤x≤1000 \leq x \leq 100)——分别表示 Dr. Evil 拥有的集合的大小以及期望的 MEX 值。

第二行包含 nn 个互不相同的非负整数(均不超过 100100),表示该集合。

输出格式

The only line should contain one integer — the minimal number of operations Dr. Evil should perform.

唯一的一行应包含一个整数——Dr. Evil 所需执行的最少操作次数。

输入输出样例

  • 输入#1

    5 3
    0 4 5 6 7

    输出#1

    2
  • 输入#2

    1 0
    0

    输出#2

    1
  • 输入#3

    5 0
    1 2 3 4 5

    输出#3

    0

说明/提示

For the first test case Dr. Evil should add 1 and 2 to the set performing 2 operations.

For the second test case Dr. Evil should erase 0 from the set. After that, the set becomes empty, so the MEX of it is 0.

In the third test case the set is already evil.

对于第一个测试用例,邪恶博士应向集合中添加 1 和 2,共执行 2 次操作。

对于第二个测试用例,邪恶博士应从集合中删除 0。此后,集合变为空集,因此其 MEX 为 0。

对于第三个测试用例,该集合本身已是“邪恶”的。

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

首页