You are given n <= 1e6 numbers, all a[i] <= 1e6, among all pairs of indices (i, j), such that i != j you need to find the maximum value of (a[i] + a[j]) * (j — i). Only one solution involving something similar to D&C DP optimization is known to me, are there any other solutions?
We can use bit mask dp also. Note (a[I]+a[j])<= $$$2*10^6$$$. We can fix this value and find max value of (j-i).
can you explain a bit please? How mask dp would work? and complexity of your program
This problem. You can either read koosaga's editorial or ICPC 2017 problem D editorial (same problem).