#P16460. [UOI 2026] Minimum Deletion
[UOI 2026] Minimum Deletion
题目描述
You are given an array of non-negative integers from to .
You are allowed to perform the following operation:
- choose one element and delete it from the array.
You need to find the minimum number of operations after which the smallest missing non-negative integer will be no greater than .
输入格式
The first line contains two integers and --- the number of elements in the array and the given number.
The second line contains integers --- the elements of the array.
输出格式
Print one integer --- the minimum number of elements that need to be deleted.
10 2
0 0 1 0 1 2 0 9 2 1
2
8 5
1 4 2 3 7 5 9 8
0
10 10
0 1 2 3 4 5 6 7 8 9
0
提示
In the first example, it is necessary to make the smallest missing element of the array no greater than .
The best choice is to delete all occurrences of the number . This requires operations.
After that, the number will be missing from the array, so the smallest missing element of the array will be equal to .
In the second example, the number is already missing from the array. Since , no operations are needed.
In the third example, all elements of the array are no greater than , so the number is definitely missing from the array. Since , no operations are needed.
Scoring
- ( points): ;
- ( points): ;
- ( points): all values are pairwise distinct;
- ( points): no additional constraints.