For the fourth hole of
's golf course, he would like you to simply play a game of Blackjack.Unfortunately, cards with various numbers on them. After shuffling, the cards are in some fixed order. You may repeatedly take cards in the order they are in until either there are no more cards or the sum of the values of your cards exceeds
.
Being sneaky, you snuck a peek at the order of the cards after shuffling (typically the player does not know what card will be next, making it a game of luck). You then have to figure out how many cards you should accept before stopping, to ensure you don't exceed a total sum of while being as close to it as possible.
Input Specification
There will be positive integers ranging from
to
inclusive, each on their own separate line. This is the order in which the cards are received.
The final line will be on its own line, to indicate the last of the input.
Note that it is not necessary to read in all lines of input.
Output Specification
Output the number of cards you can accept without exceeding 21, or output All
if you can accept all .
Scoring
If the program has the correct output, you will receive a score of (for each test case):
if the length of the code in bytes exceeds
if the length of the code in bytes is less than
where
is the length of code in bytes, if
Sample Input 1
5
2
7
5
3
-1
Sample Output 1
4
Explanation for Sample Output 1
You can accept the first cards, which totals to
. If you try to accept the
th number, your total will increase to
, which exceeds
.
Sample Input 2
1
7
10
1
2
-1
Sample Output 2
All
Explanation for Sample Output 1
You can accept all cards in this case.
Comments