CF457B.Distributed Join

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

First line contains two integer numbers, mm and nn ( 1<=m,n<=1051<=m,n<=10^{5} ). Second line contains description of the first cluster with mm space separated integers, aia_{i} (1<=ai<=109)(1<=a_{i}<=10^{9}) . Similarly, third line describes second cluster with nn space separated integers, bib_{i} (1<=bi<=109)(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=112+6+3=11 operations

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

输入输出样例

  • 输入#1

    2 2
    2 6
    3 100
    

    输出#1

    11
    
  • 输入#2

    2 3
    10 10
    1 1 1
    

    输出#2

    6
    

说明/提示

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=112+6+3=11 operations

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

首页