#K59882. Winning Dice Game Strategy
Winning Dice Game Strategy
Winning Dice Game Strategy
You are given two sets of dice. The first set, yours, contains n dice and the second set, your opponent's, contains m dice. Each die is represented by the number of sides it has. You are allowed to rearrange your dice in any order. After sorting both dice sets in descending order, you compare them pairwise. In each round, if your die has a strictly greater number of sides than the opponent's corresponding die, you win that round.
You win the game if you can win at least k rounds. Mathematically, if we denote the sorted sequences as \(a_1, a_2, \dots, a_n\) and \(b_1, b_2, \dots, b_m\) respectively, you win a round if:
[ a_i > b_i \quad \text{for some } i ]
If there is no corresponding opponent's die (i.e. when \(i > m\)), it is automatically considered a win.
Your task is to determine whether it is possible to achieve at least k wins by rearranging your dice.
inputFormat
The input is read from stdin and has the following format:
- The first line contains three integers n, m, and k, where n is the number of your dice, m is the number of opponent's dice, and k is the required number of round wins.
- The second line contains n space-separated integers representing the number of sides on each of your dice.
- The third line contains m space-separated integers representing the number of sides on each of the opponent's dice.
outputFormat
Output a single word to stdout:
possible
if you can win at least k rounds.impossible
otherwise.
3 3 2
6 8 10
5 7 9
possible