P6726 [COCI 2015/2016 #5] POPLAVA
Description
There is a histogram consisting of $N$ columns. From left to right, the heights of the columns are $h_1,h_2,\dots,h_N$.
Now you need to pour water into it. The capacity of the histogram is defined as the maximum amount of water it can store when the water structure is “stable”, i.e. the water will not flow under gravity. The figure below shows a stable example.

More specifically, let the water height on each column from left to right be $v_1,v_2,\dots,v_N$. Let $s_i=h_i+v_i$. It is a stable state when the following conditions are satisfied:
- For any $i\geq2$, when $v_i>0$, we have $s_i\le s_{i-1}$.
- For any $i\le N-1$, when $v_i>0$, we have $s_i\le s_{i+1}$.
- $v_1=v_N=0$.
Now you need to choose a permutation of $1\sim N$ as the heights $h_1,h_2,\dots,h_N$ of the columns such that the capacity of the histogram is $X$. If it does not exist, output `-1`. If there are multiple solutions, output any one.
Input Format
Input one line with two integers $N,X$.
Output Format
If no solution exists, output `-1`.
Otherwise output one line with $N$ integers, $h_1,h_2,\dots,h_N$. **Output any valid solution. This problem uses SPJ.**
Explanation/Hint
#### Sample Explanation
##### Sample $1$
$v_1=0,v_2=1,v_3=0$.
##### Sample $2$
$v_1=0,v_2=0,v_3=1,v_4=0$.
##### Sample $3$
This sample corresponds to the figure in the statement.
#### Constraints
For $100\%$ of the testdata, $1\le N\le 10^6$, $1\le X\le 10^{15}$.
#### Note
**Translated from [COCI2015-2016](https://hsin.hr/coci/archive/2015_2016/) [CONTEST #5](https://hsin.hr/coci/archive/2015_2016/contest5_tasks.pdf) *T4 POPLAVA***.
Translated by ChatGPT 5