AmazonOA #151
Find K-Level Permutation
估计中等可在线判题
Given N and an even K, construct a permutation of 1..N such that, among the sums of all contiguous subarrays of length K, the difference between the maximum and the minimum is at most 1. You may return any permutation that satisfies the condition. The full definition was recovered by cross-checking the Amazon source of the same problem with Codeforces 1927E.
输入格式
One line with two integers N K. Constraints added by this site: 2≤K≤N≤200000, and K is even.
输出格式
Output N integers representing a permutation that satisfies the condition. Any valid permutation is accepted; it need not match the order in the examples or the solution.
样例 1
输入:
7 4
输出:
1 7 3 5 2 6 4
样例说明
The fixed OAMaster example output is [1,7,3,5,2,6,4]; the sums of the four windows of length 4 are 16, 17, 16, 17.