P29466 [洛谷] [COCI2015-2016#5] POPLAVA
普及+
题目描述

Problem Description

There is a histogram composed of $N$ columns, with the heights of the columns from left to right being $h_1, h_2, \dots, h_N$.

You need to store water in this histogram. The capacity of the histogram is defined as the maximum amount of water that can be stored in a "stable" structure, meaning that the water will not flow under the influence of gravity. The following image is an example of a stable structure.

Specifically, let the height of the water on each column from left to right be $v_1, v_2, \dots, v_N$. Let $s_i = h_i + v_i$, and the structure is stable when the following conditions are met:

  • For any $i \geq 2$, when $v_i > 0$, $s_i \leq s_{i-1}$;
  • For any $i \leq N-1$, when $v_i > 0$, $s_i \leq s_{i+1}$;
  • $v_1 = v_N = 0$.

You need to choose a permutation of $1 \sim N$ as the heights of the columns $h_1, h_2, \dots, h_N$ to make the capacity of the histogram equal to $X$. If no such arrangement exists, output -1. If there are multiple solutions, output any one of them.

Input Format

The input consists of two integers $N$ and $X$ on a single line.

Output Format

If no solution exists, output -1.

Otherwise, output a single line containing $N$ integers, which are the heights $h_1, h_2, \dots, h_N$. Any valid solution is acceptable, as this problem uses a special judge.

Sample Input and Output

Sample Input #1

3 1

Sample Output #1

3 1 2

Sample Input #2

4 1

Sample Output #2

4 3 1 2

Sample Input #3

8 17

Sample Output #3

6 2 3 1 8 4 5 7

Notes

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 image in the problem.

Data Constraints

For $100\%$ of the data, $1 \leq N \leq 10^6$, $1 \leq X \leq 10^{15}$.

Notes

This problem is translated from COCI2015-2016 CONTEST #5 T4 POPLAVA.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 1
样例输出
3 1 2