A11229 | Mahmoud and Ehab and the MEX
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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?
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?
输入格式
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.
The second line contains $n$ distinct non-negative integers not exceeding $100$ that represent the set.
输出格式
The only line should contain one integer — the minimal number of operations Dr. Evil should perform.
输入输出样例
输入 #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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted