I. Distance
time limit per test
6.0 s
memory limit per test
1024 MB
input
standard input
output
standard output
There are nn points on a horizontal line, labelled with 11 through nn from left to right.
The distance between the ii-th point and the (i+1)(i+1)-th point is aiai.
For each integer kk ranged from 11 to nn, you are asked to select exactly kk different given points on the line to maximize the sum of distances between all pairs of selected points.
Input
The input contains several test cases, and the first line contains a positive integer TT indicating the number of test cases which is up to 10001000.
For each test case, the first line contains an integer nn indicating the number of points, where 2≤n≤1052≤n≤105.
The second line contains (n−1)(n−1