#P11837. [USACO25FEB] Making Mexes B
[USACO25FEB] Making Mexes B
Description
You are given an array of non-negative integers (). In one operation, you can change any element of to any non-negative integer.
The mex of an array is the minimum non-negative integer that it does not contain. For each in the range to inclusive, compute the minimum number of operations you need in order to make the mex of equal .
Input Format
The first line contains .
The next line contains .
Output Format
For each in the range to , output the minimum number of operations for on a new line. Note that it is always possible to make the mex of equal to any in the range to .
4
2 2 2 0
1
0
3
1
2
Hint
For Sample 1:
- To make the mex of equal to , we can change to (or any positive integer). In the resulting array, , is the smallest non-negative integer that the array does not contain, so is the mex of the array.
- To make the mex of equal to , we don't need to make any changes since is already the smallest non-negative integer that does not contain.
- To make the mex of equal to , we need to change the first three elements of . For example, we can change to be .
SCORING:
- Inputs 2-6:
- Inputs 7-11: No additional constraints.
京公网安备 11011102002149号