#P6726. [COCI 2015/2016 #5] POPLAVA

[COCI 2015/2016 #5] POPLAVA

Description

There is a histogram consisting of NN columns. From left to right, the heights of the columns are h1,h2,,hNh_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 v1,v2,,vNv_1,v_2,\dots,v_N. Let si=hi+vis_i=h_i+v_i. It is a stable state when the following conditions are satisfied:

  • For any i2i\geq2, when vi>0v_i>0, we have sisi1s_i\le s_{i-1}.

  • For any iN1i\le N-1, when vi>0v_i>0, we have sisi+1s_i\le s_{i+1}.

  • v1=vN=0v_1=v_N=0.

Now you need to choose a permutation of 1N1\sim N as the heights h1,h2,,hNh_1,h_2,\dots,h_N of the columns such that the capacity of the histogram is XX. If it does not exist, output -1. If there are multiple solutions, output any one.

Input Format

Input one line with two integers N,XN,X.

Output Format

If no solution exists, output -1.

Otherwise output one line with NN integers, h1,h2,,hNh_1,h_2,\dots,h_N. Output any valid solution. This problem uses SPJ.

3 1
3 1 2
4 1
4 3 1 2
8 17
6 2 3 1 8 4 5 7

Hint

Sample Explanation

Sample 11

v1=0,v2=1,v3=0v_1=0,v_2=1,v_3=0.

Sample 22

v1=0,v2=0,v3=1,v4=0v_1=0,v_2=0,v_3=1,v_4=0.

Sample 33

This sample corresponds to the figure in the statement.

Constraints

For 100%100\% of the testdata, 1N1061\le N\le 10^6, 1X10151\le X\le 10^{15}.

Note

Translated from COCI2015-2016 CONTEST #5 T4 POPLAVA.

Translated by ChatGPT 5