#abc216e. E - Amusement Park
E - Amusement Park
Score : points
问题陈述
高桥来到了一个游乐园。
该游乐园共有 个游乐设施。第 个游乐设施的初始乐趣值为 。
当高桥乘坐第 个游乐设施时,会发生以下事件序列:
- 高桥的 满意度 将会增加当前第 个游乐设施的乐趣值。
- 然后,第 个游乐设施的乐趣值减少 。
高桥的满意度初始为 。他最多可以任意顺序乘坐游乐设施总共 次。
高桥最终可能获得的最大满意度是多少?
除了乘坐游乐设施外,没有任何因素会影响高桥的满意度。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Takahashi has come to an amusement park.
The park has attractions. The fun of the -th attraction is initially .
When Takahashi rides the -th attraction, the following sequence of events happens.
- Takahashi's satisfaction increases by the current fun of the -th attraction.
- Then, the fun of the -th attraction decreases by .
Takahashi's satisfaction is initially . He can ride the attractions at most times in total in any order.
What is the maximum possible value of satisfaction Takahashi can end up with?
Other than riding the attractions, nothing affects Takahashi's satisfaction.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum possible value of satisfaction that Takahashi can end up with.
Sample Input 1
3 5
100 50 102
Sample Output 1
502
Takahashi should ride the first attraction twice and the third attraction three times.
He will end up with the satisfaction of .
There is no way to get the satisfaction of or more, so the answer is .
Sample Input 2
2 2021
2 3
Sample Output 2
9
Takahashi may choose to ride the attractions fewer than times in total.
update @ 2024/3/10 09:35:14