#arc128e. [arc128_e]K Different Values
[arc128_e]K Different Values
Problem Statement
Given are a sequence of integers and an integer .
Consider making a sequence of integers that satisfies both of the following conditions.
- For each integer (), contains exactly occurrences of . does not contain other integers.
- For every way of choosing consecutive elements from , their values are all distinct.
Determine whether it is possible to make that satisfies the conditions. If it is possible, find the lexicographically smallest such .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
If it is impossible to make a sequence that satisfies the conditions, print -1
. If it is possible, print the lexicographically smallest such .
Sample Input 1
3 3
2 2 1
Sample Output 1
1 2 3 1 2
Two sequences satisfy the conditions. The lexicographically smaller one, , is the answer.
Sample Input 2
3 2
2 1 2
Sample Output 2
1 2 3 1 3
Sample Input 3
3 3
1 3 3
Sample Output 3
-1