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.
Sort machines by cost so that a machine plus any cheaper partner forms a prefix, then pair each machine with the best affordable prefix.