Left as an exercisegoodwill wrote:How do you prove the greedy is always correct?

Here's one of the step of the proof:
Suppose A<B<C<D, we have matching between A-C and B-D, then we can always get better matching if we have A-B and C-D instead.
It follows that the matchings do not cross each other
Now, suppose we have matching between A-D and B-C, then A-B and C-D is a better matching. (follows from (x+y)^2>=x^2+y^2)
It follows that the matching do not overlap each other
If the matchings don't cross or overlap each other, then we can make then as close as possible, and the closest possible is between consecutive elements.
Now, you have to prove that the greedy choice is correct i.e. how to iteratively construct the solution.