No.5 Number Blocks
Problem Statement
Ellen is about to play with number blocks.
Each block with a number written on it has height $1$ and width $W_i$.
(There may be multiple blocks with the same width.)
These blocks are put into a box of height 1 and width L.
Ellen wondered how many blocks could fit into the large box.
However, she realized that there are so many combinations that it would be hard, and night seems likely to fall soon.
On her behalf, find the maximum number of blocks that can fit into the large box.
Input
$L$ $N$ $W_1 W_2 W_3\dots W_N$
The first line gives $L (1 \le L \le 10000)$, the width of the large box.
The second line gives $N(1 \le N \le 10000)$, the number of blocks.
The third line gives $Wi(1 \le Wi \le L )$, the width of each block, separated by half-width spaces.
Output
Output the computed value. Add a newline at the end.
Sample
Sample 1
Input
16 3 10 5 7
Output
2
Not all of them fit into the box of width 16, but up to 2 blocks can be put in.
Sample 2
Input
100 10 14 85 77 26 50 45 66 79 10 3
Output
5
The combination 14,26,45,10,3 gives the maximum of 5 blocks (no combination can fit 6 or more blocks)
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。