atcoder#ARC147C. [ARC147C] Min Diff Sum
[ARC147C] Min Diff Sum
Score : points
Problem Statement
people, numbered , are going to stand on the number line. Let's denote by the coordinate the Person stands at. Then, should be an integer satisfying . Multiple people can occupy the same coordinate.
We define the dissatisfaction level as the following formula:
$\displaystyle\sum_{i=1}^{N-1}\sum_{j=i+1}^{N}|x_j-x_i|$
Find the minimum possible value of the dissatisfaction level.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3
1 3
2 4
5 6
4
If we let , we get the dissatisfaction level of . We cannot make it or less, so the answer is .
3
1 1
1 1
1 1
0
6
1 5
2 4
1 1
4 4
3 6
3 3
15