SP14955 DCOWS - Dancing Cows
Description
It's the spring dance and, in a rare occurrence, the N (1 ≤ N ≤ 5000) bulls have been invited to dance with the M (N < M ≤ 5000) cows (as long as they stay on their very best behavior).
Farmer John, almost obsessive-compulsive in his organization of dances, wants the spectacle to be as visually attractive as possible. Thus, he wants to pair up the N bulls with cow partners such that the total of all the magnitudes of differences in height is minimized. Bulls have heights B\_i (1 ≤ B\_i ≤ 1,000,000) and cows have height C\_i (1 ≤ C\_i ≤ 1,000,000). Of course, some cows will be unmatched since N-M of them will have no partners; ignore their heights.
**INPUT FORMAT:**
\* Line 1: Two space-separated integers: N and M.
\* Lines 2..N+1: Line i+1 contains a single integer: B\_i.
\* Lines N+2..M+N+1: Line i+N+1 contains a single integer: C\_i.
**OUTPUT FORMAT:**
\* Line 1: A single integer that is the minimum of the sum of the absolute value of the height differences that can be achieved.
**SAMPLE INPUT :**
```
5 7
10
16
12
10
13
7
17
12
10
9
6
11
```
**SAMPLE OUTPUT :**
```
4
```
**INPUT DETAILS:**
```
Five bulls + seven cows with various heights:
Bulls: 10 10 12 13 16
Cows: 6 7 9 10 11 12 17
```
**OUTPUT DETAILS :**
```
Here is one way to achieve a total difference of 4:
Bulls: 10 10 12 13 16
Cows: 6 7 9 10 11 12 17
```
Input Format
N/A
Output Format
N/A