21667_BlackJack

2022-5-16 18:20| 发布者: Hocassian| 查看: 17| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505743103200-Problem List-采集的数据-后羿采集器.html

Pro.ID

21667

Title

Black Jack

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21667

AC

0

Submit

6

Ratio

0.00%

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    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
    6
    10 10 7 3 2 3
    8
    1 1 1 1 10 10 1 1

    Sample Output

    1
    1

    Source

    样例输入

    2
    6
    10 10 7 3 2 3
    8
    1 1 1 1 10 10 1 1

    样例输出

    1
    1

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部