Problem : Given an array A of integers,you can remove some elements as per your wish without changing the order of the remaining elements. After removing, value of A becomes sum(i*A[i]) from i = 1 to K(new size of A). Find maximum value of A possible after modification.
Example:
A = [-1,-9,0,5,-7]
Answer = 14 (remove -9 and -7 so value = -1*1 + 0*2 + 5*3)
I feel it is dp but cannot visualise it. Can anyone please help me out here?
You can write dp[i][j], i — which element you take in A array, j — how many elements did you already took, dp[i][j] — value, max sum, if you took j elements from first i in array A.
what are the constraints on size of the array
Check editorial of https://codeforces.me/problemset/problem/573/E