Sum of absolute difference between each pair of element in a set

207 Views Asked by At

I have a set of non negative integers, let me call this set $A$, the set has $n$ number of elements. The sum of all elements in the set is $s$, and the sum of absolute difference between each pair of elements in set $A$ is $x$. Is it possible that there exists another set $B$ (which contains non-negative integers) with $n$ elements and has sum $s$ and sum of absolute difference between each pair of elements as $x$?

1

There are 1 best solutions below

1
On BEST ANSWER

Take $A = \{0, 4, 5\}$ and $B = \{1, 2, 6 \}$. Then $0 + 4 + 5 = 9 = 1 + 2 + 6$ and $|4-0| + |5-4] + |5-0| = 10 = |2-1|+|6-2|+|6-1|$.

Edit. Answer to the comment. Let $a < b < c$. Then $s = a+b+c$ and $x = (b-a) + (c-b)+ (c-a) = 2(c-a)$. Thus, for your question, $c-a$ and $a+b+c$ are fixed. Two equations for three unknowns, you could write the general solutions if you wish. I just wrote down two solutions with three (small) different integers.