AmazonOA #246
Inventory Processes Survival Possibility
估计中等可在线判题
Each time, choose any two current tasks to fight; the one with more robots wins and absorbs all of the other's robots, and with equal counts either side may win. This continues until only one task remains. Output, in ascending order, every original 1-based index for which at least one process lets that task survive to the end.
输入格式
The first line contains n; the second line contains the robot counts. 1≤n≤200000, 1≤count≤10^9. Task indices are distinct, while counts may be equal.
输出格式
Output the 1-based indices of all tasks that can survive, in ascending order, separated by spaces.
样例 1
输入:
5
1 6 2 7 2
输出:
2 4
样例 2
输入:
2
1 1
输出:
1 2
样例 3
输入:
3
1 2 3
输出:
2 3
样例说明
The answers are 2 4, 1 2 and 2 3. In a fight between equal counts, whichever task you pick is allowed to win.