← 返回 amazon 的题目列表Maximize Weighted Sum Permutation with Lexicographic Tie-Break
类型:online_judge
amazon
Given a list of integers data with length n, generate a permutation p consisting of numbers from 1 to n such that the information gain is maximized. The information gain is calculated as: sum of i * data[p[i]]. If there are multiple permutations yielding maximum information gain, return the lexicographically smallest one.
Input
An integer list data with n elements.
Output
An integer list representing the lexicographically smallest permutation yielding maximum information gain.
Example
Input: [2, 1, 2, 3]
Output: [2, 1, 3, 4]
Example
Input
[2, 1, 2, 3]