#P1049. [NOIP 2001 普及组] 装箱问题
[NOIP 2001 普及组] 装箱问题
Description
There is a box with capacity , and there are items. Each item has a volume.
Now choose any number of items from the items (possibly none) to put into the box, so that the remaining space in the box is minimized. Output this minimum value.
Input Format
The first line contains a single integer , indicating the capacity of the box.
The second line contains a single integer , indicating the total number of items.
The next lines each contain a positive integer, where the -th line gives the volume of the -th item.
Output Format
Output a single integer in one line, indicating the minimal remaining space in the box.
24
6
8
3
12
7
9
7
0
Hint
Constraints:
- .
- .
Source: NOIP 2001 Junior, Problem 4.
Translated by ChatGPT 5
京公网安备 11011102002149号