logo AlgoBeat OnlineJudge
登录 注册

#217577. [ICPC 2018 Jiaozuo R] Distance

内存限制:512 MiB 时间限制:6000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

There are points on a horizontal line, labelled with through from left to right.

The distance between the -th point and the -th point is .

For each integer ranged from to , you are asked to select exactly different given points on the line to maximize the sum of distances between all pairs of selected points.

输入格式

The input contains several test cases, and the first line contains a positive integer indicating the number of test cases which is up to .

For each test case, the first line contains an integer indicating the number of points, where .

The second line contains positive integers , where .

We guarantee that the sum of in all test cases is up to .

输出格式

For each test case, output a line containing integers, the -th of which is the maximum sum of distances in case . You should output exactly one whitespace between every two adjacent numbers and avoid any trailing whitespace in this line.

样例

样例输入 1

1
5
2 3 1 4

样例输出 1

0 10 20 34 48

数据范围与提示

The figure below describes the sample test case.

:::align{center} :::

The only best selection for should choose the leftmost and the rightmost points, while a possible best selection for could contain any extra point in the middle.