绝对电影AI (CI翻译)
You find yourself with two arrays of positive integers $a$ and $b$, both of length $n$. You are to perform the following operation any number of times:
你有两个长度均为 $n$ 的正整数数组 $a$ 和 $b$。你可以执行任意次以下操作:AI (CI翻译)
- select an integer
$i$($1 \le i \le n$) and swap$a_i$and$b_i$.
- 选择一个整数
$i$($1 \le i \le n$),交换$a_i$和$b_i$。
Determine the maximum value of $\max(a) + \sum^{n}_{i = 1}{b_i}$ attainable if you perform the operations optimally.
请确定通过最优地执行这些操作,能够得到的 $\max(a) + \sum^{n}_{i = 1}{b_i}$ 的最大值。AI (CI翻译)
Input
输入格式
AI (CI翻译)Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.
每个输入包含多组测试用例。第一行包含测试用例数量 $t$($1 \le t \le 10^4$)。接下来是各测试用例的描述。AI (CI翻译)
The first line of each testcase contains an integer $n$ ($1 \le n \le 10^5$) — the length of the arrays $a$ and $b$.
每个测试用例的第一行包含一个整数 $n$($1 \le n \le 10^5$),表示数组 $a$ 和 $b$ 的长度。AI (CI翻译)
The second line of each testcase contains $n$ integers $a_1,a_2,\ldots,a_{n}$ ($1 \le a_i \le 10^9$).
每个测试用例的第二行包含 $n$ 个整数 $a_1,a_2,\ldots,a_{n}$($1 \le a_i \le 10^9$)。AI (CI翻译)
The third line of each testcase contains $n$ integers $b_1,b_2,\ldots,b_{n}$ ($1 \le b_i \le 10^9$).
每个测试用例的第三行包含 $n$ 个整数 $b_1,b_2,\ldots,b_{n}$($1 \le b_i \le 10^9$)。AI (CI翻译)
It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.
保证所有测试用例的 $n$ 之和不超过 $10^5$。AI (CI翻译)
Output
输出格式
AI (CI翻译)For each testcase, output the maximum value of $\max(a) + \sum^{n}_{i = 1}{b_i}$ attainable.
对于每个测试用例,输出通过操作能够得到的 $\max(a) + \sum^{n}_{i = 1}{b_i}$ 的最大值。AI (CI翻译)
Note
说明
AI (CI翻译)Test Case 3: No swaps are required, so the answer is $\max([1, 2, 3]) + 4 + 5 + 6 = 3 + 15 = 18$, it can be proven that this is optimal.
测试用例 3: 不需要交换,因此答案为 $\max([1, 2, 3]) + 4 + 5 + 6 = 3 + 15 = 18$。可以证明这是最优的。AI (CI翻译)
Test Case 4: You can achieve the maximum by swapping indices $1$, $3$ and $4$. So we get:
测试用例 4: 交换下标 $1$、$3$ 和 $4$ 可以得到最大值。此时:AI (CI翻译)
$a = [1, 3, 5, 8]$$b = [2, 4, 6, 7]$
$a = [1, 3, 5, 8]$$b = [2, 4, 6, 7]$
This gives an answer of $\max([1, 3, 5, 8]) + 2 + 4 + 6 + 7 = 8 + 19 = 27$, it can be proven that this is optimal.
答案为 $\max([1, 3, 5, 8]) + 2 + 4 + 6 + 7 = 8 + 19 = 27$。可以证明这是最优的。AI (CI翻译)
样例
4
1
2
1
1
1
2
3
1 2 3
4 5 6
4
2 3 6 7
1 4 5 8
3
3
18
27
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。