← 返回 walmartlabs 的题目列表Remove M Elements to Minimize Unique IDs in an Array
类型:online_judge
Given an integer array arr and an integer m, remove exactly m elements from the array (you may remove elements at any indices). After removal, make the number of distinct integers (unique IDs) in the remaining array as small as possible.
Return the minimum possible number of distinct integers after removing m elements.
Input (stdin)
Line 1: integer n, the length of the array.
Line 2: n integers, the array arr.
Line 3: integer m, the number of elements to remove.
Output (stdout)
One integer: the minimum possible distinct count.
Constraints
1 <= n <= 2 * 10^5
0 <= m <= n
-10^9 <= arr[i] <= 10^9
Examples
Example 1:
Input:
7
5 5 4 3 3 3 2
2
Output:
3
Example
Input
7
5 5 4 3 3 3 2
2
Output
3