#P4650. [COCI 2017/2018 #5] Karte

[COCI 2017/2018 #5] Karte

Description

There are NN cards stacked together. On the ii-th card, there is a number aia_i, meaning that at least aia_i cards below it have incorrect information. If there are indeed at least aia_i cards below it with incorrect information, then the information on this card is correct; otherwise, the information on this card is incorrect. (We consider that below the bottom card there are 00 incorrect cards.)

Now you need to rearrange the order of the cards so that exactly KK cards have incorrect information.

Input Format

The first line contains two positive integers NN and KK (1N5×105,0KN)(1 \le N \le 5 \times 10^5, 0 \le K \le N), representing the number of cards and the required number of incorrect pieces of information.

The next NN lines each contain one number, representing the corresponding aia_i (0ai5×105)(0 \le a_i \le 5 \times 10^5).

Output Format

If no rearrangement exists, output 1-1. Otherwise, output the aia_i of the NN cards from top to bottom. If there are multiple solutions, output any one.

4 2
1 2 2 3

2 3 1 2
5 3
2 1 3 0 3

3 3 0 1 2
6 4
0 2 5 2 0 1

-1

Hint

For 30%30\% of the testdata, N16N \le 16.

For another 40%40\% of the testdata, N2000N \le 2000.

Explanation of Sample 2:

The 55-th card shows 22, but there are only 00 incorrect cards below it, so it is incorrect.

The 44-th card shows 11. There is 11 incorrect card below it (the 55-th), so it is correct.

The 33-th card shows 00. There is 11 incorrect card below it (the 55-th), so it is correct.

The 22-th card shows 33, but there is only 11 incorrect card below it (the 55-th), so it is incorrect.

The 11-st card shows 33, but there are only 22 incorrect cards below it (the 55-th and the 22-nd), so it is incorrect.

Therefore, there are 33 incorrect cards in total.

Translated by ChatGPT 5