Problem 3814 · Medium

Maximum Capacity Within Budget

Sort machines by cost so that a machine plus any cheaper partner forms a prefix, then pair each machine with the best affordable prefix.

Open the interactive visualisation