cswork / OA打开练习工作台

SalesforceOA #7

Construct Winning Sequence

估计中等可在线判题

考点(AI 标注)贪心调度模拟/实现

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.

输入格式

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

输出格式

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

样例 1

输入:

5 1 2

输出:

-1

样例 2

输入:

5 4 11

输出:

5
10 11 10 9 8

样例 3

输入:

6 5 10

输出:

6
9 10 9 8 7 6

样例说明

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