#B4111. Delicious Dorayaki Sum

    ID: 11768 Type: Default 1000ms 256MiB

Delicious Dorayaki Sum

Delicious Dorayaki Sum

JOI-kun loves making dorayaki. He uses N types of fillings and M types of pancakes. The deliciousness value of a dorayaki made from the i-th filling (with tastiness ai) and the j-th pancake (with tastiness bj) is defined as:

\[ (a_i+b_j)\times \max(a_i,b_j), \]

where \(\max(x,y)\) denotes the maximum of \(x\) and \(y\). Your task is to compute the sum of the deliciousness values for all \(N\times M\) possible dorayaki.

inputFormat

The input consists of three lines:

The first line contains two integers (N) and (M).

The second line contains (N) integers (a_1, a_2, \ldots, a_N), representing the tastiness values of the fillings.

The third line contains (M) integers (b_1, b_2, \ldots, b_M), representing the tastiness values of the pancakes.

outputFormat

Output a single integer representing the sum of deliciousness of all possible dorayaki.

sample

2 2
1 2
3 4
71