Pro.ID21667 TitleBlack Jack Title链接http://10.20.2.8/oj/exercise/problem?problem_id=21667 AC0 Submit6 Ratio0.00% 时间&空间限制描述Netease Interactive Entertainment (NIE) is interesting in developing funny leisure games for users. Nowadays some engineers are doing research on a famous game called Black Jack. Here let’s make the rules a little simpler. Considering that only the banker and you play the game with a number of cards valued form 1 to 10, and the game is consisted of several rounds; you and the banker play it round by round until there are less than 6 cards left. In each round of the game: (1) The banker and you must take two cards one by one in order, that means first the banker take one card, and then you take one, then the banker, and then you. After that the banker and you take turns to make some "call", the banker first. (2) When it's one's turn to make a "call", he can choose to take one more card or not. But if one chose not to take the card, he can not make "call" any more in this round. (3) When it's the banker's turn to make a "call", if the sum of his cards is not greater than 16, he must take one more card. Or else he will not take the card. (4) If one's sum of his cards is larger than 21, he loses and this round ends immediately. (5) When it's your turn to make a "call", if the banker can't make "call" any more and the sum of your cards is already larger than the banker's, you must choose not to take the card and this round ends. (6) If both you and the banker choose not to take the card, or there is no card left, the banker wins this round if the sum of his card is not less than yours, otherwise you win this round. Now given N cards in order, one of the most valuable information that the engineers want to know is the number of rounds that you can win at most, could you help them? 输入The first line of input will be a positive integer T ≤ 15, T test cases follow. For each case, there will be two lines. The first line will be a positive integer N ≤ 1000, representing the number of cards. Then N positive integers follow the next line, each number will be larger than 0 and less than 11, representing the value of the given N cards. 输出Description Netease Interactive Entertainment (NIE) is interesting in developing funny leisure games for users. Nowadays some engineers are doing research on a famous game called Black Jack. Here let’s make the rules a little simpler. Considering that only the banker and you play the game with a number of cards valued form 1 to 10, and the game is consisted of several rounds; you and the banker play it round by round until there are less than 6 cards left. In each round of the game: (1) The banker and you must take two cards one by one in order, that means first the banker take one card, and then you take one, then the banker, and then you. After that the banker and you take turns to make some "call", the banker first. (2) When it's one's turn to make a "call", he can choose to take one more card or not. But if one chose not to take the card, he can not make "call" any more in this round. (3) When it's the banker's turn to make a "call", if the sum of his cards is not greater than 16, he must take one more card. Or else he will not take the card. (4) If one's sum of his cards is larger than 21, he loses and this round ends immediately. (5) When it's your turn to make a "call", if the banker can't make "call" any more and the sum of your cards is already larger than the banker's, you must choose not to take the card and this round ends. (6) If both you and the banker choose not to take the card, or there is no card left, the banker wins this round if the sum of his card is not less than yours, otherwise you win this round. Now given N cards in order, one of the most valuable information that the engineers want to know is the number of rounds that you can win at most, could you help them? Input The first line of input will be a positive integer T ≤ 15, T test cases follow. For each case, there will be two lines. The first line will be a positive integer N ≤ 1000, representing the number of cards. Then N positive integers follow the next line, each number will be larger than 0 and less than 11, representing the value of the given N cards. Output For each test case, output an integer on a single line, the number of rounds that you can win at most. Sample Input 2 Sample Output 1 Source 样例输入2 样例输出1 作者 |