cswork / OA打开练习工作台

AmazonOA #28

Find Optimal Permutation

估计简单可在线判题

考点(AI 标注)贪心调度原地数组

Output a permutation p of 1..n that maximizes Σ i×data[p[i]−1], where i starts from 1. If the maximum is tied, choose the lexicographically smallest index permutation.

输入格式

The first line contains n (1..100000); the second line contains n positive integers (1..10⁹).

输出格式

Output n indices.

样例 1

输入:

3
2 1 2

输出:

2 1 3

样例 2

输入:

1
7

输出:

1

样例 3

输入:

3
3 3 1

输出:

3 1 2

样例说明

Example 1: the values in order are 1, 2, 2, and the two equal 2s are placed by original indices 1, 3, so the output is 2 1 3 with sum 11. Example 2: the only possible output is 1. Example 3: value 1 goes first, followed by indices 1, 2, so the output is 3 1 2.