Game Prediction
Time limit1sMemory limit128 MB
Given your n distinct cards in an m-player game where every card from 1 to n*m is dealt, find the most rounds you can guarantee to win against any opponent play.
- Level
Hard8 of 10
- Topics
- Greedy, Sorting, Combinatorics, Math
- Solved
- No attempts yet
Problem
There are people, including you, playing a special card game. At the start, each player is dealt cards. Every card shows a distinct positive integer pip between and ; no two cards share the same pip.
In each round, every player plays one of their cards and the cards are compared. The player who plays the card with the largest pip wins that round, and the next round begins. After rounds every card has been played, and the player who has won the most rounds wins the game.
Given the cards you were dealt, write a program that determines the maximum number of rounds you can guarantee to win, no matter how your opponents play.
Input
The input consists of several test cases. The first line of each case contains two integers () and (), the number of players and the number of cards each player is dealt. The next line contains positive integers, the pips of the cards you were dealt. A blank line separates consecutive cases.
The input is terminated by a line containing two zeros.
Output
For each test case, print a line in the form Case x: y, where is the test case number (starting from ) and is the maximum number of rounds you can guarantee to win in that game.