#t543. 志愿推荐
志愿推荐
School Recommendation
Problem Description
There are schools, the -th of which has an expected admission cutoff ; and there are students, the -th of whom has an estimated score .
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 , the number of schools and the number of students respectively.
The second line contains non-negative integers , the expected cutoffs of the schools.
The third line contains non-negative integers , 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 schools have cutoffs ; the students have estimated scores .
- The first student's score is ; its difference from cutoff is , so the dissatisfaction is .
- The second student's score is ; its difference from cutoff is , so the dissatisfaction is .
- The third student's score is ; its difference from cutoff is , so the dissatisfaction is .
The total dissatisfaction is .
Constraints
- For of the data: , ;
- For of the data: , .