Perfect Pairing
View as PDFYou are given two arrays and
, each containing
integers.
You must pair every element of with exactly one element of
, and every element of
must be used in exactly one pair.
If you pair values and
, that pair contributes
to the total cost.
Find the minimum possible total cost over all perfect pairings.
Input
The first line contains an integer .
The second line contains integers
.
The third line contains integers
.
Output
Print one integer: the minimum possible total cost.
Constraints
Example 1
Input
3
4 1 8
2 9 5
Output
3
Example 2
Input
5
7 -3 12 0 6
10 -1 8 5 -4
Output
6
Comments