## COCI '15 Contest 5 #4 Poplava

View as PDF

Points: 12
Time limit: 1.0s
Memory limit: 64M

Problem types

Mirko dreamt of a histogram last night that consists of columns. Each column is one meter wide and the heights of the columns in meters are .

The capacity of a histogram is the maximal amount of water that a histogram can hold so that the configuration of the water is "stable", or, in other words, that it doesn’t move under the influence of gravity. The image on the right depicts an example of a stable configuration.

Formally, let us denote the heights of water above the columns with .

The configuration of the water is stable if the following holds:

• , for each such that
• , for each such that
• and

When Mirko woke up, he wanted to know whether he could somehow choose the heights of columns that are a permutation of the set {} such that the capacity of such histogram is equal to its lucky number . Help Mirko and find one histogram that meets his requirements.

#### Input

The first line of input contains integers and .

#### Output

If a histogram of capacity exactly does not exist, output −1. Otherwise, output numbers that meet the given requirements in the first line separated by space. If there are multiple such solutions, output any.

#### Sample Input 1

3 1

#### Sample Output 1

3 1 2

#### Explanation for Sample Output 1

In this configuration, it holds , , .

#### Sample Input 2

4 1

#### Sample Output 2

4 3 1 2

#### Explanation for Sample Output 2

In this configuration it holds , , , .

#### Sample Input 3

8 17

#### Sample Output 3

6 2 3 1 8 4 5 7

#### Explanation for Sample Output 3

The sample corresponds to the image from the task.