题库练习 Distributed Join
← 上一题 下一题 →

A9655 | Distributed Join

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

First line contains two integer numbers, $m$ and $n$ ( $1<=m,n<=10^{5}$ ). Second line contains description of the first cluster with $m$ space separated integers, $a_{i}$ $(1<=a_{i}<=10^{9})$ . Similarly, third line describes second cluster with $n$ space separated integers, $b_{i}$ $(1<=b_{i}<=10^{9})$ .

输入格式

Print one integer — minimal number of copy operations.

输出格式

In the first example it makes sense to move all the rows to the second partition of the second cluster which is achieved in $2+6+3=11$ operations

In the second example Piegirl can copy each row from $B$ to the both partitions of the first cluster which needs $2·3=6$ copy operations.

输入输出样例

输入 #1
2 2
2 6
3 100
输出 #1
11
输入 #2
2 3
10 10
1 1 1
输出 #2
6
C++ 编辑器
输入
输出