← 返回 amazon 的题目列表Maximize Weighted Sum by Optimal Index Rearrangement
类型:online_judge
amazon
Given an integer array data indexed from 1, rearrange it such that [1 * data[1] + 2 * data[2] + ... + n * data[n]] is maximal. Return the rearranged index array where each element represents the index after rearrangement (starting from 1). If there are multiple equivalent answers, return the lexicographically smallest one.
Example:
data = [3, 6, 1, 4, 2] -> answer is [3, 5, 1, 4, 2] because 1 * 1 + 2 * 2 + 3 * 3 + 4 * 4 + 5 * 6 is the largest sum you can achieve.
Example
Input
3 6 1 4 2