AmazonOA #233
Get Most Out of the Data
估计中等可在线判题
Output a permutation p of 1..n that maximizes sum(i*data[p[i]]), where i and p are both interpreted as 1-based; if several permutations tie, take the lexicographically smallest. The index range 0..n in the original formula is a typo; changing the weights to 0..n−1 only shifts the result by a fixed total and does not affect the optimal permutation.
输入格式
The first line contains n; the second line contains data. The original text had no numeric bounds; this site uses 1≤n≤200000, −10^9≤data≤10^9. The output is a permutation of original array indices, not the sorted values or the rank of each element.
输出格式
Output n 1-based original indices, separated by spaces.
样例 1
输入:
3
3 1 2
输出:
2 3 1
样例 2
输入:
3
2 2 1
输出:
3 1 2
样例 3
输入:
3
-2 -1 -2
输出:
1 3 2
样例说明
The answers are 2 3 1, 3 1 2 and 1 3 2. Equal values are ordered by ascending original index.