cswork / OAOpen practice workspace

InstacartOA #2

Collect Sticks

Estimated EasyJudge-ready

Topics (AI-labelled)Simulation

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.

Input

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.

Output

The order of the indices.

Example 1

Input:

6 2
0 50 0 30 0 25

Output:

3 1 5

Example 2

Input:

8 2
40 0 0 60 0 50 0 10

Output:

3 0

Example 3

Input:

5 1
5 0 60 0 50

Output:

2 0 4

Editorial

Loading solution…