PEG Test - Halloween 2014
Ben is going trick-or-treating this Halloween.
Ben only has minutes of trick-or-treat time. He has planned out a list of houses to visit. In order to attain the maximum amount of candy possible, he will need to spend time bartering with each household. He knows that the -th house will require minutes of bartering.
Because of his excellent athletic abilities, it will take Ben exactly minute to move between any pair of houses.
Determine the maximum number of houses Ben can visit on Halloween night. Note that he can begin at any house and visit the houses in any order, but will only receive candy from a house at the end of the bartering period.
Input Specification
Line of input contains two integers ,
.
Line of input will have space-separated integers - the time in
minutes it takes to barter with the -th house. .
Output Specification
Output a single integer, the greatest number of houses Ben can receive candy from.
Sample Input 1
4 12
4 2 5 4
Sample Output 1
3
Explanation 1
Ben can spend minutes bartering at the first house, move to the second house in minute, spend minutes bartering with the second house, move to the fourth house in minute, and spend minutes bartering at the fourth house. This will take a total of minutes.
Sample Input 2
2 10
9 1
Sample Output 2
1
Explanation 2
Ben can spend minutes collecting candy from the first house, but will not have enough time to move to the second house to barter.
Comments