Problem D
Majór Skýrsla

Languages en is

You have been assigned the task of ordering and preparing a report for a British major. This major does mathematics research in his spare time, so he appreciates patterns and sequences in everything he sees. When he recieves a stack of papers he likes to consider the index of the stack. Each page has some information on it, and this info is of varying importance. This index is calculated by going through the stack from top to bottom and adding up all the page numbers where the page is more important than the one following it. So if the third page he reads is more important then the fourth he adds three to the index. Can you order the $n$ pages of the report so its index is $k$, the major’s favourite number?


The first and only line of input contains two integers $n$, the number of pages, where $1 \leq n \leq 10^5$, and $k$, the major’s favourite number, where $0 \leq k \leq \frac{n \cdot (n-1)}{2}$.


Print the numbers $1, 2, \dots , n$ in some order on a single line, separated by spaces. The first number denotes the page the major will read first and the last number the page he will read last. The least important page is denoted by $1$, the second least important page is denoted by $2$, and so on, up to $n$, which denotes the most important page. Your output is considered correct if the stack it represents has the index $k$.

For example, if $n=5$ and $k=4$, then the output $5 2 4 1 3$ is considered correct, since the first and third page are more important than the one that follows, so the index is $1+3=4$.

Sample Input 1 Sample Output 1
5 4
5 2 4 1 3

Please log in to submit a solution to this problem

Log in