Random Game
Time limit1sMemory limit128 MB
Pick win probabilities for the games so the lower of the two players' expected scores is as large as possible.
- Level
Medium7 of 10
- Topics
- Binary search, Math, Greedy
- Solved
- No attempts yet
Problem
At the start of the new term the TCLAB members went on a retreat to Yangpyeong. To loosen up the mood they sat down in a circle to play games, but everyone liked a different game. So they settled on a random game, where several games are mixed together and one of them is drawn according to a fixed probability distribution. Mixing the games lets every participant reach a decent average satisfaction.
Suppose Jeong and Ha are on the retreat, and the two player board games Balloon Cup, Rummikub, Lost Cities and Avalon are available. The satisfaction each of them assigns to each game is below.
If the games are drawn with the distribution below, both players end up with an average satisfaction of 7.5. In this example no distribution pushes the lower of the two averages above 7.5.
Define the satisfaction matrix as follows. The set of participants is and the set of games is , and is the satisfaction that participant assigns to game . Write for the probability that game is played. Then the average satisfaction of participant is . By the definition of probability every is at least 0 and .
Given the satisfactions of the two participants, find the maximum value of over all probability distributions. Only that maximum is asked for, so you do not print the distribution that achieves it.
This problem deals only with the case of two participants.
Input
Input is read from standard input. The first line has the number of test cases (). The first line of each test case has the number of games (). The second line has the satisfactions of participant 1 for games 1 through in order, separated by spaces, and the third line has the satisfactions of participant 2 in the same order. Every satisfaction is an integer from 0 to 10000.
Output
Write the answers to standard output. For each test case print the maximum of the smallest average satisfaction on a line of its own. Round the value at the third decimal place and print two decimal places: round up when the third decimal digit is 5 or more, and drop it otherwise. Print both decimals even when the answer is a whole number, as in 3.00.