Card Captor Sanggeun
InterviewTime limit1sMemory limit128 MB
Simulate a two-player card game where each player always plays the smallest legal card, and report the final scores.
- Level
Easy3 of 10
- Topics
- Simulation, Implementation, Greedy, Array
- Solved
- No attempts yet
Problem
A card game like the following is popular at a certain school.
- It uses cards, each printed with one distinct integer from to .
- The cards are split between two players, cards each.
- The two players take turns playing one card at a time, following these rules:
- If there is no card on the table, a player may play any card.
- If there is a card on the table, a player may only play a card whose number is larger than the last card played.
- If a player has no card they can play, the turn passes to the opponent and every card currently on the table is discarded.
- The game starts with no card on the table.
- The game ends as soon as either player has played all of their cards.
- When the game ends, each player earns a score equal to the number of cards the opponent is still holding.
Sanggeun and Geunsang face off in this game. The game starts on Sanggeun's turn, and the two players have agreed to always play the smallest-numbered card among those they are allowed to play. Given the cards dealt to each player, write a program that outputs the scores of Sanggeun and Geunsang.
Input
The first line contains . ()
Each of the next lines contains one number printed on a card dealt to Sanggeun. Every card from to that Sanggeun did not receive is dealt to Geunsang.
Output
Print Sanggeun's score on the first line and Geunsang's score on the second line.