Problem 1499 · Hard

Max Value of Equation

For each point, the best partner to its left maximises y minus x there, which a monotonic deque keeps at the front.

Open the interactive visualisation