We present a different method of obtaining the bound Z⩽n(n−1). As in the previous solution, we reduce the problem to the case xi∈{−1,1}. For brevity, we use the notation [2n]={1,2,…,2n}.
Consider any x1,x2,…,x2n∈{−1,1}. Let
A={i∈[2n]:xi=1} and B={i∈[2n]:xi=−1}.
For any subsets X and Y of [2n] we define
e(X,Y)=r<s,r∈X,s∈Y∑(s−r−n).
One may observe that
e(A,A)+e(A,B)+e(B,A)+e(B,B)=e([2n],[2n])=∑1⩽r<s⩽2n(s−r−n)=−3(n−1)n(2n−1).
Therefore, we have
Z=e(A,A)−e(A,B)−e(B,A)+e(B,B)=2(e(A,A)+e(B,B))+3(n−1)n(2n−1).(5)
Thus, we need to maximize e(A,A)+e(B,B), where A and B form a partition of [2n].
Due to the symmetry, we may assume that ∣A∣=n−p and ∣B∣=n+p, where 0⩽p⩽n. From now on, we fix the value of p and find an upper bound for Z in terms of n and p.
Let a1<a2<⋯<an−p and b1<b2<⋯<bn+p list all elements of A and B, respectively. Then
e(A,A)=1⩽i<j⩽n−p∑(aj−ai−n)=i=1∑n−p(2i−1−n+p)ai−(2n−p)⋅n(6)
and similarly
e(B,B)=i=1∑n+p(2i−1−n−p)bi−(2n+p)⋅n.(7)
Thus, now it suffices to maximize the value of
M=i=1∑n−p(2i−1−n+p)ai+i=1∑n+p(2i−1−n−p)bi.(8)
In order to get an upper bound, we will apply the rearrangement inequality to the sequence a1,a2,…,an−p,b1,b2,…,bn+p (which is a permutation of 1,2,…,2n ), together with the sequence of coefficients of these numbers in (8). The coefficients of ai form the sequence
n−p−1,n−p−3,…,1−n+p
and those of bi form the sequence
n+p−1,n+p−3,…,1−n−p
Altogether, these coefficients are, in descending order:
- n+p+1−2i, for i=1,2,…,p;
- n−p+1−2i, counted twice, for i=1,2,…,n−p; and
−(n+p+1−2i), for i=p,p−1,…,1.
Thus, the rearrangement inequality yields
M⩽i=1∑p(n+p+1−2i)(2n+1−i)+i=1∑n−p(n−p+1−2i)((2n+2−p−2i)+(2n+1−p−2i))−i=1∑p(n+p+1−2i)i(9)
Finally, combining the information from (5), (6), (7), and (9), we obtain
Z⩽3(n−1)n(2n−1)−2n((2n−p)+(2n+p))+2i=1∑p(n+p+1−2i)(2n+1−2i)+2i=1∑n−p(n−p+1−2i)(4n−2p+3−4i),
which can be simplified to
Z⩽n(n−1)−32p(p−1)(p+1).
Since p is a nonnegative integer, this yields Z⩽n(n−1).