Problem E
Poplava
Mirko dreamt of a histogram last night that consists of
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. Figure 1 depicts an example of a stable configuration.
![\includegraphics[width=93px]{picture.png}](/problems/poplava/file/statement/en/img-0001.png)
Formally, let us denote the heights of water above the
columns with
-
, 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
Input
The first line of input contains integers
Output
If a histogram of capacity exactly
Sample Input 1 | Sample Output 1 |
---|---|
3 1 |
3 1 2 |
Sample Input 2 | Sample Output 2 |
---|---|
4 1 |
4 3 1 2 |
Sample Input 3 | Sample Output 3 |
---|---|
8 17 |
6 2 3 1 8 4 5 7 |