cswork / OA打开练习工作台

IntuitOA #2

The Chosen Ones — Queue Iterations

简单可在线判题

考点(AI 标注)模拟/实现单调栈与堆

Given n non-negative integers and an integer x, perform x rounds. In each round, take up to x numbers from the front of the queue and select the maximum among them; on ties, select the one closest to the front. Decrease each of the other values by 1 (to a minimum of 0) and put them back at the end of the queue in their original relative order. Output the original 1-based indices of the selected elements.

输入格式

The first line contains n and x, and the second line contains n non-negative integers. Site limits: 1≤x≤n≤1000, 0≤queue[i]≤10⁹. x≤n is a site limit that guarantees the queue is non-empty at the start of every round.

输出格式

Output the original indices of the x selected elements in the order they were selected, separated by spaces.

样例 1

输入:

7 5
1 2 2 3 4 5 5

输出:

5 6 7 4 1

样例 2

输入:

1 1
0

输出:

1

样例 3

输入:

2 1
0 0

输出:

1

样例说明

The original sample input came without an output. Simulating round by round according to the original text, the indices selected for that sample are 5 6 7 4 1.