InstacartOA #2
Collect Sticks
估计简单可在线判题
考点(AI 标注)模拟/实现
The bird starts from an empty position, first goes right to take the nearest non-empty stick and returns to the start, then alternates left and right until the total length of the sticks taken is at least 100. It is guaranteed that there is always a stick in the required direction. Output the 0-based indices taken.
输入格式
n≤2000, n lengths (0..10⁹, where 0 means empty), and the 0-based empty position bird; the start is empty, and until the cumulative length reaches at least 100, there is always a stick to take in the current direction. The internal cumulative length may exceed 32 bits.
输出格式
The order of the indices.
样例 1
输入:
6 2
0 50 0 30 0 25
输出:
3 1 5
样例 2
输入:
8 2
40 0 0 60 0 50 0 10
输出:
3 0
样例 3
输入:
5 1
5 0 60 0 50
输出:
2 0 4