303408: CF660F. Bear and Bowling 4
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Bear and Bowling 4
题意翻译
给一个长度为$n$ 的序列,第$i$ 个数是$a_i$ ,选取一个连续子序列$\{a_x,a_{x+1},\dots ,a_{x+k-1}\}$ 使得$\sum_{i=1}^k i\cdot a_{x+i-1}$ 最大。 其中$1\leq n\leq 2\times 10^5,|a_i|\leq 10^7$ 感谢@Durant_Lee 提供的翻译题目描述
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 the $ i $ -th roll is multiplied by $ i $ and scores are summed up. So, for $ k $ rolls with scores $ s_{1},s_{2},...,s_{k} $ , the total score is ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF660F/dc22606298d977fae92bc67b7a4815c447193831.png). The total score is $ 0 $ if there were no rolls. Limak made $ n $ rolls and got score $ a_{i} $ for the $ i $ -th of them. He wants to maximize his total score and he came up with an interesting idea. He can say that some first rolls were only a warm-up, and that he wasn't focused during the last rolls. More formally, he can cancel any prefix and any suffix of the sequence $ a_{1},a_{2},...,a_{n} $ . It is allowed to cancel all rolls, or to cancel none of them. The total score is calculated as if there were only non-canceled rolls. So, the first non-canceled roll has score multiplied by $ 1 $ , the second one has score multiplied by $ 2 $ , and so on, till the last non-canceled roll. What maximum total score can Limak get?输入输出格式
输入格式
The first line contains a single integer $ n $ ( $ 1<=n<=2·10^{5} $ ) — the total number of rolls made by Limak. The second line contains $ n $ integers $ a_{1},a_{2},...,a_{n} $ ( $ |a_{i}|<=10^{7}) $ — scores for Limak's rolls.
输出格式
Print the maximum possible total score after cancelling rolls.
输入输出样例
输入样例 #1
6
5 -1000 1 -3 7 -8
输出样例 #1
16
输入样例 #2
5
1000 1000 1001 1000 1000
输出样例 #2
15003
输入样例 #3
3
-60 -70 -80
输出样例 #3
0