Problem 3971 · Hard

Maximum Total Value

Each index gives smaller gains every time it is picked, so greedily take the largest current gain, m times, while it stays positive.

Open the interactive visualisation