cswork / OA打开练习工作台

UberOA #35

Farthest Seat Assignment

估计中等评测数据准备中,可先阅读题面

考点(AI 标注)迭代器设计单调栈与堆

Design the assignment behavior for a row of n</c

Constraints

When no seats are occupied yet, assign seat 0.

Example 1

Input:

n = 10
count = 5

Output:

[0,9,4,2,6]

Explanation: The first two assignments take the ends. The third assignment chooses seat 4, which is one of the middle seats farthest from 0 and 9; ties use the smaller index.

Example 2

Input:

n = 3
count = 4

Output:

[0,2,1]

Explanation: Only three seats exist, so only three assignments are returned.