Codeforces Round 695 (Div. 2)
C
Three Bags
Codeforces
1900
原题
← BD →
翻译中…

You are given three bags. Each bag contains a non-empty multiset of numbers. You can perform a number of operations on these bags. In one operation, you can choose any two non-empty bags, and choose one number from each of the bags. Let's say that you choose number $a$ from the first bag and number $b$ from the second bag. Then, you remove $b$ from the second bag and replace $a$ with $a-b$ in the first bag. Note that if there are multiple occurrences of these numbers, then you shall only remove/replace exactly one occurrence.

翻译中…

You have to perform these operations in such a way that you have exactly one number remaining in exactly one of the bags (the other two bags being empty). It can be shown that you can always apply these operations to receive such a configuration in the end. Among all these configurations, find the one which has the maximum number left in the end.

翻译中…

Input

翻译中…

The first line of the input contains three space-separated integers $n_1$, $n_2$ and $n_3$ ($1 \le n_1, n_2, n_3 \le 3\cdot10^5$, $1 \le n_1+n_2+n_3 \le 3\cdot10^5$) — the number of numbers in the three bags.

翻译中…

The $i$-th of the next three lines contain $n_i$ space-separated integers $a_{{i,1}}$, $a_{{i,2}}$, ..., $a_{{i,{{n_i}}}}$ ($1 \le a_{{i,j}} \le 10^9$) — the numbers in the $i$-th bag.

翻译中…

Output

翻译中…

Print a single integer — the maximum number which you can achieve in the end.

翻译中…

Note

翻译中…

In the first example input, let us perform the following operations:

翻译中…

$[1, 2], [6, 3, 4, 5], [5]$

翻译中…

$[-5, 2], [3, 4, 5], [5]$ (Applying an operation to $(1, 6)$)

翻译中…

$[-10, 2], [3, 4], [5]$ (Applying an operation to $(-5, 5)$)

翻译中…

$[2], [3, 4], [15]$ (Applying an operation to $(5, -10)$)

翻译中…

$[-1], [4], [15]$ (Applying an operation to $(2, 3)$)

翻译中…

$[-5], [], [15]$ (Applying an operation to $(-1, 4)$)

翻译中…

$[], [], [20]$ (Applying an operation to $(15, -5)$)

翻译中…

You can verify that you cannot achieve a bigger number. Hence, the answer is $20$.

翻译中…

样例

Input #1
2 4 1
1 2
6 3 4 5
5
Output #1
20
InputCopy OutputCopy
Input #2
3 2 2
7 5 4
2 9
7 1
Output #2
29
InputCopy OutputCopy
题目信息
题号
1467C
时间限制
1 s
内存限制
256 MB
标签
构造
贪心

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。