#t543. 志愿推荐

志愿推荐

School Recommendation

Problem Description

There are mm schools, the ii-th of which has an expected admission cutoff aia_i; and there are nn students, the ii-th of whom has an estimated score bib_i.

Now we must recommend one school for each student. For a given student, among all schools the one whose cutoff differs least from the student's estimated score is recommended; this minimal difference (in absolute value) is called that student's dissatisfaction. Compute the sum of all students' dissatisfaction.

Input Format

The first line contains two positive integers m,nm, n, the number of schools and the number of students respectively.

The second line contains mm non-negative integers a1,a2,…,ama_1, a_2, \dots, a_m, the expected cutoffs of the schools.

The third line contains nn non-negative integers b1,b2,…,bnb_1, b_2, \dots, b_n, the estimated scores of the students.

Output Format

Output one line containing a single non-negative integer: the sum of all students' dissatisfaction.

Sample Input

4 3
513 598 567 689
500 600 550

Sample Output

32

Sample Explanation

The m=4m=4 schools have cutoffs 513,598,567,689513, 598, 567, 689; the n=3n=3 students have estimated scores 500,600,550500, 600, 550.

  • The first student's score is 500500; its difference from cutoff 513513 is ∣500−513∣=13|500-513|=13, so the dissatisfaction is 1313.
  • The second student's score is 600600; its difference from cutoff 598598 is ∣600−598∣=2|600-598|=2, so the dissatisfaction is 22.
  • The third student's score is 550550; its difference from cutoff 567567 is ∣550−567∣=17|550-567|=17, so the dissatisfaction is 1717.

The total dissatisfaction is 13+2+17=3213+2+17=32.

Constraints

  • For 30%30\% of the data: 1≤n,m≤1031\le n,m\le 10^3, 0≤ai,bi≤1040\le a_i,b_i\le 10^4;
  • For 100%100\% of the data: 1≤n,m≤1051\le n,m\le 10^5, 0≤ai,bi≤1060\le a_i,b_i\le 10^6.