CF573E.Bear and Bowling
NOI/NOI+/CTSC
通过率:0%
时间限制:6.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Limak is an old brown bear. He often goes bowling with his friends. Today he feels really good and tries to beat his own record!
For rolling a ball one gets a score — an integer (maybe negative) number of points. Score for i-th roll is multiplied by i and scores are summed up. So, for k rolls with scores _s_1, _s_2, ..., s__k, total score is
. Total score is 0 if there were no rolls.
Limak made n rolls and got score a__i for i-th of them. He wants to maximize his total score and he came up with an interesting idea. He will cancel some rolls, saying that something distracted him or there was a strong wind.
Limak is able to cancel any number of rolls, maybe even all or none of them. Total score is calculated as if there were only non-canceled rolls. Look at the sample tests for clarification. What maximum total score can Limak get?
Limak 是一只年迈的棕熊。他经常和朋友们一起去打保龄球。今天他感觉特别好,打算打破自己的纪录!
每次投球会得到一个分数——一个整数(可能为负数)分。第 i 次投球的分数将乘以 i,然后将所有加权后的分数相加。因此,对于 k 次投球,其分数分别为 s1,s2,…,sk,总分为
。
若未进行任何投球,则总分为 0。
Limak 进行了 n 次投球,第 i 次投球得分为 ai。他希望最大化自己的总分,并想出了一个有趣的方法:他可以取消其中若干次投球,理由可能是“有东西分散了他的注意力”或“当时刮了强风”。
Limak 可以取消任意次数的投球,甚至可以全部取消或一次也不取消。总分仅基于未被取消的投球来计算(即被取消的投球视作从未发生)。请参考样例测试以进一步理解题意。Limak 能获得的最大总分是多少?
输入格式
The first line contains single integer n (1 ≤ n ≤ 105).
The second line contains n space-separated integers _a_1, _a_2, ..., a__n (|a__i| ≤ 107) - scores for Limak's rolls.
第一行包含一个整数 n(1≤n≤105)。
第二行包含 n 个以空格分隔的整数 a1,a2,…,an(∣ai∣≤107),表示 Limak 每次掷骰子所得的分数。
输出格式
Print the maximum possible total score after choosing rolls to cancel.
输出选择取消掷骰子后可能获得的最高总分。
输入输出样例
输入#1
5 -2 -8 0 5 -3
输出#1
13
输入#2
6 -10 20 -30 40 -50 60
输出#2
400
说明/提示
In first sample Limak should cancel rolls with scores - 8 and - 3. Then he is left with three rolls with scores - 2, 0, 5. Total score is 1·( - 2) + 2·0 + 3·5 = 13.
In second sample Limak should cancel roll with score - 50. Total score is 1·( - 10) + 2·20 + 3·( - 30) + 4·40 + 5·60 = 400.
在第一个样例中,Limak 应当取消得分分别为 −8 和 −3 的两次投掷。之后他剩下三次投掷,得分分别为 −2、0、5。总得分为 1⋅(−2)+2⋅0+3⋅5=13。
在第二个样例中,Limak 应当取消得分为 −50 的一次投掷。总得分为 1⋅(−10)+2⋅20+3⋅(−30)+4⋅40+5⋅60=400。
输入解题思路,AI测评打分。不知道怎么写?