DWITE Online Computer Programming Contest, October 2007, Problem 4
Some kids play with blocks, and build things by stacking different blocks on top of each other. Given a set of blocks and a target height, we want to find out if it's possible to construct a stack with an exact specified height.
The input will contain at least lines, one positive integer value per line. The first line will contain an integer , the target height for the stack.
The second line will contain an integer , number of blocks in a set.
The next lines will contain integers, one per line; ; representing the height of blocks in the set.
The output file will contain a single integer value, a minimum number of blocks out of the supplied set, required to build a stack of the given height. If it is impossible to build the desired stack, output .
Sample Input 1
5 3 1 2 3
Sample Output 1
Sample Input 2
10 3 1 5 7
Sample Output 2