Card Counting Club
시간 제한8초메모리 제한1024 MB
각 플레이어의 가장 낮은 카드가 지면 벌점이 붙는 게임을 시뮬레이션하고, 카드가 바닥나는 순서대로 플레이어 이름을 출력한다.
문제
During the creation of the Card Counting Club, the club wanted to combine their card counting practice along with the process of choosing player order for their games. They converged on a counting-out game that is played like so:
-
At the beginning of the game, each player is dealt a hand with the same number of cards as everyone else.
-
Each player begins the turn by showing the card with the smallest value in their hand to the other players.
-
The player with the smallest card gets to discard it.
-
Only one player gets to discard their card, and the ties are broken by choosing the player’s whose name comes first lexicographically (i.e. standard dictionary order).
-
All players that do not get to discard their card leave a small mark on their card and place it back into their hand. Each mark increases the value of the card by an agreed penalty amount.
-
-
When a player runs out of cards, they are counted out.
-
The game is played until all players are counted out.
Once the game is over, the order of players as they were counted out is used to choose the order in which the club members get to play other games.
Over time, the club grew to 35 people, and the cost of the cards along with the time it takes to play out the game became too much. So, the club turns to you to make a program that will play out the game for them to save both time and the cost of the playing cards.
입력
The first line contains three integers , , and ) where is the number of players, is the hand size of each player, and is the penalty amount for each mark. The next lines contain the name of the player followed by space-separated integers ( for each ) representing the values of the cards in the player’s hand. The values may repeat both within and between hands. Each player’s name will consist only of uppercase letters and will have length between and .
출력
On a single line, display the list of player names in the order in which they are counted out in regular play of the game. Consecutive names on this line should be separated with a single space.