#P4419. [COCI2017-2018#1] Cezar
[COCI2017-2018#1] Cezar
题目描述
Little Caesar likes card games. Everytime he comes to Zagreb, he plays blackjack, the famous card game, with his friends.
In this game, the player draws cards while the sum of the cards in his hand is less than or equal to 21 or until he says “DOSTA” (Croatian for “STOP”).
At the beginning of the game, there are 52 cards in the deck, thirteen ranks of each of the four suits. The card ranks are two, three, …, ten, Jack, Queen, King and Ace. The card values are the following: the cards with numbers on them are worth that number (e.g., “nine” is 9), the cards with pictures (Jack, Queen, and King) are worth 10, whereas the Ace is worth 11.
Caesar has found himself in an interesting situation. During the game, he already drew N cards whose sum is less than or equal to 21 and is now having second thoughts about drawing one more card or not. Let’s assume X is the difference from the sum of the cards so far to 21. Everybody knows that you don’t draw a card if the number of the remaining cards in the deck whose value is greater than X is greater than or equal to the number of the remaining cards in the deck whose value is less than or equal to X.
Since Caesar is having a difficult time calculating whether he needs to draw another card or not, he’s asking you to do it for him.
输入格式
The first line of input contains the positive integer N (1 ≤ N ≤ 52), the number of cards Caesar has drawn so far.
Each of the following N lines contains a single positive integer, the value of the card Caesar drew.
输出格式
If Caesar should draw another card, output “VUCI” (Croatian for “DRAW”), otherwise output “DOSTA” (Croatian for “STOP”).
题目大意
小凯撒喜欢玩纸牌游戏,每次他去萨格勒布(克罗地亚的首都 ——译者注)都会和他的朋友们玩 点,这是一种很流行的纸牌游戏。
这个游戏的规则是,在纸牌点数之和小于 点之前可以连续抓牌,如果决定不抓牌,则喊 DOSTA
(克罗地亚语“停止”的意思)。
游戏开始时,桌面有 张牌 —— 种不同牌面的牌,每种有 个花色。牌面分别是 。它们的点数计算规则是:牌面上的数字就是点数(比如, 的点数就是 ),特殊地, 都算 点, 算 点。
凯撒认为游戏的乐趣在于,当抓了 张牌之后,如果点数之和小于或等于 ,他就要思考是否要再多抓一张。假设 是已抓牌点数之和与 之间相差的点数值,我们知道,如果桌面上的剩余牌中点数大于 的纸牌数量比小于等于 的纸牌数量要多,或两者一样多,那就不应该再抓牌了。
因为凯撒并不擅于计算是否需要抓牌,所以他请你帮他计算和决策。
【输入格式】
第一行输入一个正整数 (),表示凯撒已经抓牌的张数。
接下来 行每行一个正整数,第 个正整数是他抓的第 张牌点数值。
【输出格式】
如果凯撒应该继续抓牌,输出 VUCI
(克罗地亚语“抓牌”的意思),否则输出 DOSTA
(克罗地亚语“停止”的意思)。
【样例解释】
第一个样例: 已经抓的 张牌的总点数是 ,它与 的差 是 。桌面上剩余牌中比 大的牌有 张(分别是 张 、 张 、 张 、 张 、 张 、 张 、 张 、 张 ),而比 小的牌有 张(分别是 张 、 张 、 张 、 张 、 张 ),所以决定不再抓牌,输出 DOSTA
。
6
2
3
2
3
2
3
DOSTA
1
10
VUCI
2
5
6
VUCI
提示
Clarification of the first test case:
The sum of the already drawn cards is 15, and the difference X to 21 is 6. The number of cards in the deck with a value greater than 6 is 32 (4 Aces, 4 Kings, 4 Queens, 4 Jacks, 4 tens, 4 nines, 4 eights, and 4 sevens), whereas the number of cards in the deck with a value less than or equal to 6 is 14 (one two, one three, 4 fours, 4 fives, and 4 sixes).