[Solution] Maximum Median Matching CodeChef Solution
boys and girls attend a dance class, where is odd. For today's practice session, they need to form boy-girl pairs.
The -th boy has a happiness value of and the -th girl has a happiness value of . A pair consisting of the -th boy and the -th girl has a happiness value of .
Let the happiness values of the pairs be . The dance instructor would like it if many of the pairs have a high happiness value, and passes the task to you — find the maximum possible value of the median of , if the boy-girl pairs are chosen optimally.
Note: The median of a odd-sized list of integers is the middle number when they are sorted. For example, the median of is , the median of is , and the
median of is .
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- Each test case consists of three lines of input.
- The first line of each test case contains a single integer .
- The second line of each test case contains space-separated integers — the happiness values of the boys.
- The third line of each test case contains space-separated integers — the happiness values of the girls.
Output Format
For each test case, output on a new line the maximum possible median happiness of the pairs.
Constraints
- is odd
- for each valid
- The
No comments:
Post a Comment