This page is still under construction.

Parts of this page are still being built. What you see may change.

Random Game

Time limit1sMemory limit128 MB

Summary
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.

ParticipantBalloon CupRummikubLost CitiesAvalon
Jeong55105
Ha51055

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.

GameProbability of being played
Balloon Cup0
Rummikub1/2
Lost Cities1/2
Avalon0

Define the satisfaction matrix VV as follows. The set of participants is D={1,2}D = \{1, 2\} and the set of games is G={1,2,…,n}G = \{1, 2, \dots, n\}, and VijV_{ij} is the satisfaction that participant jj assigns to game ii. Write pip_i for the probability that game ii is played. Then the average satisfaction of participant jj is Vj=∑i=1nVijpiV_j = \sum_{i=1}^{n} V_{ij} p_i. By the definition of probability every pip_i is at least 0 and ∑i=1npi=1\sum_{i=1}^{n} p_i = 1.

Given the satisfactions of the two participants, find the maximum value of min⁡1≤j≤2Vj\min_{1 \le j \le 2} V_j 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 TT (1≤T≤201 \le T \le 20). The first line of each test case has the number of games NN (1≤N≤1061 \le N \le 10^6). The second line has the satisfactions of participant 1 for games 1 through NN 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 min⁡1≤j≤2Vj\min_{1 \le j \le 2} V_j 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.

Examples1

  1. Example 1

    Input
    2
    2
    2 3
    3 0
    3
    1 2 3
    4 5 6
    
    Expected output
    2.25
    3.00