시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 17 | 9 | 8 | 50.000% |
Tanaka has gotten interested in Dacian mythology (the Dacians were a people that lived in the area of Romania before the Romans). In this mythology, Zalmoxis, was supreme god, and Pleistoros was god of war. In Tanaka’s new interpretation of this mythology, Zalmoxis has a new powerful attack, the ZalPunch, and loves ZalSequences.
The ZalPunch is an attack that can be applied to non-negative integer sequences. It consists of taking a strictly positive integer x from the sequence and replacing it with two occurrences of x – 1. For example:
ZalSequences – the sequences that Zalmoxis loves – are one of the following:
For example, [30], [29, 29] and [29, 28, 27, 27] are ZalSequences, but [28, 29, 28] is not.
To begin with, Zalmoxis creates a ZalSequence of length N + K. However, one of his enemies destroys K of the values in this sequence, leaving N remaining values. Call this sequence S. Given N, K, and S, insert K values into S to create any ZalSequence of length N + K. It is guaranteed that this is possible in all test cases.
The first line of the input will contain the positive integers N and K.
The next line of the input will contain N non-negative integers, the values of S.
The first and only line of the output should contain a sequence of N + K non-negative integers that is both a ZalSequence, and contains S as a subsequence (that is, the elements of S appear on possibly non-consecutive positions in the output).
번호 | 배점 | 제한 |
---|---|---|
1 | 30 | K = 1 |
2 | 70 | No further constraints |
5 1 29 27 25 25 28
29 27 25 25 26 28
1 5 29
29 28 27 26 25 25
In the first example, [29, 27, 25, 25, 26, 28] can be obtained from [30] by the following ZalPunches:
[30] → [29, 29] →[29, 28, 28] →[29, 27, 27, 28] →[29, 27, 26, 26, 28] → [29, 27, 25, 25, 26, 28]
In the second example, [29, 28, 27, 26, 25, 25] can be obtained from [30] by the following ZalPunches:
[30] → [29, 29] →[29, 28, 28] →[29, 28, 27, 27] →[29, 28, 27, 26, 26] →[29, 28, 27, 26, 25, 25]