Question: A. Min Max Swap time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output You are given two arrays a and

A. Min Max Swap time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output You are given two arrays a and b of n positive integers each. You can apply the following operation to them any number of times:

Select an index i (1in) and swap ai with bi (i. e. ai becomes bi and vice versa). Find the minimum possible value of max(a1,a2,,an)max(b1,b2,,bn) you can get after applying such operation any number of times (possibly zero).

Input The input consists of multiple test cases. The first line contains a single integer t (1t100) the number of test cases. Description of the test cases follows.

The first line of each test case contains an integer n (1n100) the length of the arrays.

The second line of each test case contains n integers a1,a2,,an (1ai10000) where ai is the i-th element of the array a.

The third line of each test case contains n integers b1,b2,,bn (1bi10000) where bi is the i-th element of the array b.

Output For each test case, print a single integer, the minimum possible value of max(a1,a2,,an)max(b1,b2,,bn) you can get after applying such operation any number of times.A. Min Max Swap time limit per test1 second memory limit per

Example input Copy 3 6 1 2 6 5 1 2 34 3 2 2 5 3 |3 3 3 3 3 3 2 1 2 2 1 output Copy 18 9 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!