#t392. 装箱问题(boxes)
装箱问题(boxes)
Box Loading Problem
Problem Background
Special for beginners, ^_^
Problem Description
There is a box of capacity (a positive integer, ), and at the same time there are items (), each with a volume (a positive integer).
You are to pick some of the items to put into the box, so that the remaining space in the box is minimized.
Input Format
The capacity of the box.
The number of items .
The next lines, each giving the volume of one of the items.
Output Format
The remaining space in the box.
Sample Input
24
6
8
3
12
7
9
7
Sample Output
0
Constraints
Time limit: 1s, memory limit: 1024KiB for each test case.