[Solution] MEX vs DIFF Codeforces Solution | Codeforces Problem Solution 2022
You are given an array of non-negative integers. In one operation you can change any number in the array to any other non-negative integer.
Let's define the cost of the array as , where of a set of non-negative integers is the smallest non-negative integer not present in the set, and is the number of different numbers in the array.
For example, , .
You should find the minimal cost of the array if you are allowed to make at most operations.
The input consists of multiple test cases. The first line contains a single integer () — the number of test cases. Description of the test cases follows.
The first line of each test case contains two integers and (, ) — the length of the array and the number of operations that you are allowed to make.
The second line of each test case contains integers () — the elements of the array .
It is guaranteed that the sum of over all test cases does not exceed .
For each test case output a single integer — minimal cost that it is possible to get making at most operations.
No comments:
Post a Comment