cswork / OAOpen practice workspace

SalesforceOA #7

Construct Winning Sequence

Estimated MediumJudge-ready

Topics (AI-labelled)GreedySimulation

Construct n integers in the range [lo,hi] that first strictly increase and then strictly decrease; the peak is not at either end, and each phase has at least one adjacent edge. Find the lexicographically largest such sequence; output −1 if there is no solution. The original example 10,11,10,9,8, rather than the all-decreasing 11,10,..., supports forbidding an empty rising phase.

Input

One line with n lo hi. On this site 1≤n≤200000, 1≤lo≤hi≤10⁹.

Output

If there is no solution, output only −1; otherwise, first output n, then output the n elements of the sequence.

Example 1

Input:

5 1 2

Output:

-1

Example 2

Input:

5 4 11

Output:

5
10 11 10 9 8

Example 3

Input:

6 5 10

Output:

6
9 10 9 8 7 6

Example notes

The results are no solution, [10,11,10,9,8], and [9,10,9,8,7,6], respectively.

Editorial

Loading solution…