Consider two sorted arrays of integers \$X\$ and \$Y\$ of size \$m\$ and \$n\$ respectively with \$m < n\$. For example \$ X = (1,4)\$, \$Y = (2,10,11)\$.
We say that a matching is some way of pairing each element of \$X\$ with an element of \$Y\$ in such a way that no two elements of \$X\$ are paired with the same element of \$Y\$. The cost of a matching is just the sum of the absolute values of the differences in the pairs.
For example, with \$X = (7,11)\$, \$Y = (2,10,11)\$ we can make the pairs \$(7,2), (11,10)\$ which then has cost \$5+1 = 6\$. If we had made the pairs \$(7,10), (11,11)\$ the cost would have been \$3+0 = 3\$. If we had made the pairs \$(7,11), (11,10)\$ the cost would have been \$4+1 = 5\$.
As another example take \$X = (7,11,14)\$, \$Y = (2,10,11,18)\$. We can make the pairs \$(7,2), (11,10), (14,11)\$ for a cost of \$9\$. The pairs \$(7,10), (11,11), (14,18)\$ cost \$7\$.
The task is to write code that, given two sorted arrays of integers \$X\$ and \$Y\$, computes a minimum cost matching.
Test cases
[1, 4], [2, 10, 11] => [[1, 2], [4, 10]]
[7, 11], [2, 10, 11] => [[7, 10], [11, 11]]
[7, 11, 14], [2, 10, 11, 18] => [[7, 10], [11, 11], [14, 18]]