#P7319. 「PMOI-4」生成树
「PMOI-4」生成树
Description
Given numbers, the original weight of the -th number is . You need to choose these numbers one by one in some order.
Suppose it is currently the -th selection, and the chosen number has original weight . Then the weights of all other numbers that have not been chosen will each increase by .
You need to find a selection plan such that the sum of the final weights of the chosen numbers is maximized.
Input Format
The first line contains a positive integer .
The second line contains integers , representing the weight of the -th number.
Output Format
Output one integer in one line, representing the maximum sum of weights.
7
1 -1 -2 2 -3 3 4
66
Hint
[Sample Explanation]
Choosing the numbers with indices in order works.
[Constraints]
This problem uses bundled testdata.
- Subtask 1 (20pts): .
- Subtask 2 (30pts): .
- Subtask 3 (30pts): It is guaranteed that either all or all .
- Subtask 4 (20pts): No special constraints.
For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号