Provinces and Gold
InterviewTime limit1sMemory limit1024 MB
Given the counts of Gold, Silver, and Copper in a hand, find the best victory card and best treasure card Jake can afford with his total buying power.
- Level
Easy1 of 10
- Topics
- Implementation
- Solved
- No attempts yet
Problem
Jake is learning how to play the card game Dominion. In Dominion, you can buy a variety of treasure, action, and victory point cards. At the end of the game, the player with the most victory points wins!
Each turn, each player draws 5 cards and can use their action and treasure cards to get buying power, which they spend on more cards. Since Jake is just starting out, he has decided to buy only treasure and victory point cards.
So the cards he can buy are:
- Province (costs , worth victory points)
- Duchy (costs , worth victory points)
- Estate (costs , worth victory point)
There are 3 kinds of treasure cards:
- Gold (costs , worth buying power)
- Silver (costs , worth buying power)
- Copper (costs , worth buying power)
At the start of Jake's turn, he draws 5 of these cards. Given the number of Golds, Silvers, and Coppers in his hand, calculate the best victory card and the best treasure card he can buy that turn. Jake can buy only one card.
Input
The input is a single test case on a single line, containing three non-negative integers , , (). They are the number of Golds, Silvers, and Coppers Jake draws in his hand.
Output
Output the best victory card and the best treasure card Jake can buy this turn, separated with " or ", in this order. If Jake cannot afford any victory card, output only the best treasure card he can buy.
Hint
In Sample 1, Jake has 1 Silver in his hand, so his buying power is 2. That allows him to buy either an Estate or a Copper.