[Solution] Atleast and Atmost CodeChef Solution
There are hidden integer arrays of length length each. You are given the mex of each of these arrays.
Ashish likes lower bounds and Kryptonix likes upper bounds. So, for each , find:
- The least possible number of occurrences of across all the arrays
- The most possible number of occurrences of across all the arrays
Note that these values must be computed independently, i.e, it is allowed to choose different configurations of arrays to attempt to minimize/maximize the number of occurrences of different integers.
Please see the samples for an example.
Recall that the mex of an array is the smallest non-negative integer that is not present in it. For example, the mex of is , and the mex of is .
Input Format
- The first line of input contains a single integer — the number of test cases. Then the test cases follow.
- The first line of each test case contains an integer — the size of the array.
- The second line of each test case contains space-separated integers , denoting
- the mexes of the arrays.
Output Format
For each test case, output lines, each containing two space-separated integers. The -th line should contain the least and the most possible number of occurrences of across all the arrays.
Constraints
- The sum of over all test cases does not exceed
No comments:
Post a Comment