1874. Game

单点时限: 2.0 sec

内存限制: 256 MB

You are playing a computer game and a big fight is planned between two armies. You and your computer opponent will line up your respective units in two rows, with each of your units facing exactly one of your opponent’s units and vice versa. Then, each pair of units, who face each other will fight and the stronger one will be victorious, while the weaker one will be captured. If two opposing units are equally strong, your unit will lose and be captured. You know how the computer will arrange its units, and must decide how to line up yours. You want to maximize the sum of the strengths of your units that are not captured during the battle.

输入格式

There are many tests!

In each test the first line is a interger $N$ $(1 \leq N \leq 100~000)$, then next two lines both $N$ intergers $n$ $(1 \leq n \leq 1000)$ that specify the strengths of the units that you and the computer have, respectively.

输出格式

The output value should be an int, the maximum total strength of your units that are not captured.

样例

Input
5
5 15 100 1 5
5 15 100 1 5
10
1 3 5 7 9 11 13 15 17 19
2 4 6 8 10 12 14 16 18 20
Output
120
99

提示

Case 1: Your units with strengths of 100 and 15, along with one of your strength 5 units, can avoid capture.

Case 2: You assign your weakest unit to the computer’s strongest unit. Then you assign all your other units in such a way that each of your units has a strength one higher than the opposing unit. So all your units except the weakest one avoid capture.

19 人解决,47 人已尝试。

20 份提交通过,共有 97 份提交。

6.4 EMB 奖励。

创建: 16 年,3 月前.

修改: 6 年,9 月前.

最后提交: 3 年,7 月前.

来源: N/A

题目标签