Problem 2555 · Medium

Maximize Win From Two Segments

Slide a window of width k over the sorted prizes and add the best window that finishes before it, which keeps the two segments apart.

Open the interactive visualisation