Problem A
Altruistic Amphibians

The frogs realize that if a frog
Furthermore, if frog
The frogs can build even higher piles of frogs this way, the only restriction is that no frog may carry other frogs of weight in total amounting to its own weight or heavier. Once a pile has been used to allow a frog to escape, the frogs in the pile jump back to the bottom of the pit and they can then form a new pile (possibly consisting of a different set of frogs). The question is simply how many frogs can escape the pit assuming they collaborate to maximize this number?
Input
The first line of input contains two integers
Output
Output the maximum number of frogs that can escape the pit.
Sample Input 1 | Sample Output 1 |
---|---|
3 19 15 5 3 12 4 4 20 10 5 |
3 |
Sample Input 2 | Sample Output 2 |
---|---|
3 19 14 5 3 12 4 4 20 10 5 |
2 |