Given both players' block weights, compute Naomi's best scores under honest War rules and under optimal lying in Deceitful War.
Medium6GreedySortingGame theoryNo attempts yetTime limit5sMemory limit512 MBNaomi and Ken each have N identical looking wooden blocks. Every block weighs more than 0.0kg and less than 1.0kg, and all 2N weights are different.
They play a game called War with the following rules.
ChosenNaomi.ChosenNaomi.ChosenKen.Ken has exactly one strategy that maximizes his own score without assuming anything about Naomi's strategy, and he always follows it.
Naomi decides to play a different game called Deceitful War instead. Ken still believes he is playing War. Two rules change.
ToldNaomi greater than 0.0kg and less than 1.0kg. Ken takes that number to be ChosenNaomi.The scale must never expose the lie, so in every round Naomi has to satisfy both of these conditions.
ChosenNaomi > ChosenKen holds if and only if ToldNaomi > ChosenKen holds.ToldNaomi is not equal to the mass of any block Ken holds, because Ken knows that no two blocks weigh the same.Naomi knows what Ken knows and knows the optimal War strategy Ken follows, so she always predicts the block Ken will play.
You are given the masses of the blocks the two players start with. Find the score Naomi gets when she plays Deceitful War optimally, and the score she gets when she plays War optimally instead. In both cases Ken believes the two are playing War and maximizes his own score.
Two situations, for illustration.
One block is left on each side, Naomi holds 0.5kg and Ken holds 0.6kg. Ken takes the point. If Naomi announced 0.6kg or more, the scale would tip toward Ken and he would catch the lie.
Two blocks are left on each side, Naomi holds 0.7kg and 0.2kg while Ken holds 0.8kg and 0.3kg. Naomi can play her 0.2kg block and claim she picked a 0.6kg one. Ken believes her, plays his 0.8kg block and scores a point. The scale tips toward Ken exactly as he expects, so he never learns that he was deceived. In the next round Naomi plays her 0.7kg block, truthfully says 0.7kg, and scores a point. Had she played War, Ken would have scored two points and Naomi none.
The first line contains the number of test cases T. The first line of each test case contains N, the number of blocks each player has. The next line contains the masses of Naomi's N blocks separated by spaces, and the last line contains the masses of Ken's N blocks in the same format.
Every mass is written as a 0, then a decimal point, then 1 to 5 digits. Ken and Naomi do not know that the numbers in the input have at most 5 digits after the decimal point, so Naomi may claim she played a block of 0.5000001kg and Ken has no reason to doubt her.
For each test case, print one line in the form Case #x: y z. Here x is the test case number starting from 1, y is the score Naomi gets when she plays Deceitful War optimally, and z is the score she gets when she plays War optimally.