The numbers from 1 to 2
n are separated into two lists of
n numbers each, A and B; elements are ordered so a
1<a
2<...<a
n and b
1>b
2>...>b
n.
How much is |a1-b1|+|a2-b2|+...+|an-bn|?
the sum is somehere between
n and
n^2, depending on the sequences A and B.
n is the minimum, since
ai and
bi must differ by at least 1 each. And
n^2 is the maximum because the condition on A and B both inreasing means
ai and
bi can differ by at most
n.