Problem 3835 · Hard
Cost is the value spread times the length; a window that fits stays fit inside any sub-window.
Open the interactive visualisation