Maximize Power
Practice
0 (0 votes)
Geometry
Dynamic programming
Problem
17% Success 63 Attempts 50 Points 2s Time Limit 256MB Memory 1024 KB Max Code
Chuchu has got an array \(A\) of \(n\) intergers and he want to maximize the power of the array. Power of an array is defined as,
- \(Power(A) = \sum_{i=1}^{n} i \cdot A_i\)
In order to maximize the power, he is allowed to do following operation at most once,
- Pick any element from the given array and insert it at any other position.(While inserting, some elements of array get shifted accordingly).
Note: Given array \(A\) is 1-indexed.
Input:
- First line contains a integer \(n\), denoting size of array.
- Second line contains \(n \) space separated integers, each denoting \(A_i\).
Output:
Print the maximum power of array Chuchu can obtain after performing given operation at most once.
Constraints:
- \(1 \le n\le 200000\)
- \(0 \le \lvert A_i \rvert \le 10^6\)
Submissions
Please login to view your submissions
Similar Problems
Points:20
96 votes
Tags:
ReadyMathematicsApprovedEasyMathamatics
Points:50
14 votes
Tags:
Dynamic ProgrammingHardAlgorithmsMathematicsOpenApproved
Points:50
2 votes
Tags:
AlgorithmsDynamic Programming
Editorial
No editorial available for this problem.