| USI-Team-Selection 2023-2024 |
|---|
| Finished |
jiangly is pretty good at competitive programming.
Now, there are $$$n$$$ professors, each giving a grade for jiangly's competitive programming skills. The $$$i$$$-th professor gives a grade of $$$a_i$$$.
If we sort all the grades and delete the first and the last ones (minimum and maximum), the sum of the rest grades would be the final grade for jiangly. Formally, if array $$$b$$$ are the sorted grades, the final grade is:
$$$$$$ \sum_{i=2}^{n-1}{b_i} $$$$$$
If you talk to some professor about this fact, the grade this professor will give to jiangly would rise a little bit. If you talk to $$$i$$$-th professor, $$$a_i$$$ will becomes to $$$d_i(a_i \lt d_i)$$$.
You do not have much time, so you can only talk to one professor about the fact.
As you want the grade to be fair, you want to maximize jiangly's grade. Note that we sort the grades after you talk to a professor.
The first line contains an integer $$$T(1 \le T \le 10^4)$$$ — the number of test cases. The description of the test cases follows.
For each test case, the first line consists of a single integer $$$n(3 \le n \le 10^5)$$$ — the number of professors.
For each test case, the second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n(1 \le a_i \le 10^3)$$$ — the initial grade given.
For each test case, The third line consists of $$$n$$$ integers $$$d_1, d_2, \dots, d_n(a_i \lt d_i \le 10^3)$$$ — the new grade after you talk to some professor.
It is guaranteed that $$$\sum n \le 10^5$$$ for all test cases.
For each test case, print a single integer in a line — the maximum grade that jiangly can get in the end.
161 1 4 5 1 42 2 5 6 2 5
11
For case in the example, you can choose talk to the $$$3$$$-rd professor, the final grades are: $$$[1, 1, 5, 5, 1, 4]$$$, the sum of grades after delete is $$$1 + 1 + 4 + 5 = 11$$$.
| Name |
|---|


