Vera and Mean Sorting
Time limit2sMemory limit256 MB
Find the lexicographically smallest permutation of 1..N whose length-K window harmonic means are non-increasing, and which is not L-mean-sorted for any other window length L.
- Level
Medium7 of 10
- Topics
- Combinatorics, Math, Greedy, Sorting
- Solved
- No attempts yet
Problem
The harmonic mean of a sequence of positive integers is
For an array of positive integers of length , let
Vera calls -mean-sorted if holds for every with .
A permutation is an ordered list of distinct positive integers , each of them at most .
Permutation is lexicographically smaller than permutation if there is an () with such that for every with .
You are given the integers and . Among the permutations of the integers through that are -mean-sorted and are not -mean-sorted for any () with , help Vera find the lexicographically smallest one. If no such permutation exists, print .
Input
The input is given in the following format.
N K
Constraints:
- and are integers.
Output
Print the permutation on one line, with the numbers separated by single spaces. If no such permutation exists, print on one line.