P2677 [USACO07DEC] Bookshelf 2 B
Description
Farmer John recently added a huge bookshelf to the cows' library. Although it is very large, it was almost instantly filled with all kinds of books. Now, only a bit of space remains at the top of the shelf. All $N$ cows ($1 \le N \le 20$) each have a fixed height $H_i$ ($1 \le H_i \le 1{,}000{,}000$) (such tall cows >_
Input Format
Line $1$: Two space-separated integers: $N$ and $B$.
Lines $2$ to $N+1$: Line $i+1$ contains a single integer $H_i$.
Output Format
Line $1$: Output a non-negative integer, the minimal amount by which the tower’s height exceeds the shelf height.
Explanation/Hint
We choose cows $1$, $3$, $4$, and $5$ to form a tower; their total height is $3+3+5+6=17$. No arrangement can form a tower of height $16$, so the answer is $1$.
Translated by ChatGPT 5