Input: N = 4, M = 6, A[] = {6, 1, 2, 4}, B[] = {3, 5, 1, 7, 2, 3}
Output: 16
Explanation: We can choose (1, 5, 7, 2) from B[], so the sum of absolute differences will be D = |6−1| + |1−5| + |2−7| + |4−2| = 5 + 4 + 5 + 2 = 16
Input: N = 5, M = 5, A[] = {1, 2, 3, 4, 5}, B= {1, 2, 3, 4, 5}
Output: 12
Explanation: We cab choose (5,4,3,2,1) from B[], so the sum of absolute differences will be D = |1−5| + |2−4| + |3−3| + |4−2| + |5−1| = 4 + 2 + 0 + 2 + 4 = 12.