#P1898D. Absolute Beauty
Absolute Beauty
No submission language available for this problem.
Description
Kirill has two integer arrays and of length . He defines the absolute beauty of the array as Here, denotes the absolute value of .
Kirill can perform the following operation at most once:
- select two indices and () and swap the values of and .
Help him find the maximum possible absolute beauty of the array after performing at most one swap.
Each test contains multiple test cases. The first line contains the number of test cases (). The description of test cases follows.
The first line of each test case contains a single integer () — the length of the arrays and .
The second line of each test case contains integers () — the array .
The third line of each test case contains integers () — the array .
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, output one integer — the maximum possible absolute beauty of the array after no more than one swap.
Input
Each test contains multiple test cases. The first line contains the number of test cases (). The description of test cases follows.
The first line of each test case contains a single integer () — the length of the arrays and .
The second line of each test case contains integers () — the array .
The third line of each test case contains integers () — the array .
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, output one integer — the maximum possible absolute beauty of the array after no more than one swap.
Note
In the first test case, each of the possible swaps does not change the array .
In the second test case, the absolute beauty of the array without performing the swap is . After swapping the first and the second element in the array , the absolute beauty becomes . These are all the possible outcomes, hence the answer is .
In the third test case, it is optimal for Kirill to not perform the swap. Similarly to the previous test case, the answer is .
In the fourth test case, no matter what Kirill does, the absolute beauty of remains equal to .