All of you are probably very familiar with the problem of finding the longest monotone subsequence. You probably think you know all about it. In order to convince us, solve the problem “opposite” to finding the longest monotone subsequence.
For given N and K, find the sequence that consists of numbers from 1 to N such that each of the numbers in it appears exactly once and the length of its longest monotone subsequence (ascending or descending) is exactly K.
The required sequence (if it exists) is not necessarily unique, so you can output any valid sequence.
입력 4 3 출력 1 4 2 3 입력 5 1 출력 -1 입력 5 5 출력 1 2 3 4 5 Clarification of the first sample test: A sequence of length 4 with longest monotone subsequence of length 3 is (1, 4, 2, 3). The longest monotone sequence is (1, 2, 3).
출처:coci_2013-2014_contest6