#T463. 装箱问题
装箱问题
Description
There is a box with a capacity of V (a positive integer, 0 ≤ V ≤ 20000), and there are n items (0 < n ≤ 30), each with a volume (positive integer).
The task is to select any number of these items to pack into the box such that the remaining space in the box is minimized.
Input Format
Line 1: An integer representing the box capacity.
Line 2: An integer representing the number of items, n.
Lines 3 to n+2: Each line represents the volume of one of the n items.
Output Format
An integer representing the remaining space in the box.
CodesOnline