Solution:
Up to reordering the real numbers xi and yi, we may assume that y1x1≤…≤ynxn. Let A=y1x1 and B=ynxn, and S=∣x1−y1∣+…+∣xn−yn∣. Our aim is to prove that S≤2−A−B1.
First, note that we cannot have A>1, since that would imply xi>yi for all i≤n, hence x1+…+xn>y1+…+yn. Similarly, we cannot have B<1, since that would imply xi<yi for all i≤n, hence x1+…+xn<y1+…+yn.
If n=1, then x1=y1=A=B=1 and S=0, hence S≤2−A−B1.
For n≥2 let 1≤k<n be some integer such that ykxk≤1≤yk+1xk+1. We define the positive real numbers X1=x1+…+xk, X2=xk+1+…+xn, Y1=y1+…+yk, Y2=yk+1+…+yn. Note that Y1≥X1≥AY1 and Y2≤X2≤BY2. Thus, A≤Y1X1≤1≤Y2X2≤B. In addition, S=Y1−X1+X2−Y2.
From 0<X2,Y1≤1,0≤Y1−X1 and 0≤X2−Y2, follows
S=Y1−X1+X2−Y2=Y1Y1−X1+X2X2−Y2=2−Y1X1−X2Y2≤2−A−B1