D. Optimal Number Permutation
time limit per test
1 second
memory limit per test
256 megabytes
output
standard output
数组a包含从1到n的所有整数两次。你可以任意排列a中的任何数字。
让数字i位于置换数组a中的位置xi,yi(xi<yi)。让我们定义值di=yi-xi−数字i的位置之间的距离。置换数组a的数字以使总和的值最小化 s = SUM[(n-i)*abs(di+i-n)] (1 <= i <= n)
输入:
包含一个整数n(1<=n<=5e5)
输出:
打印2n个整数–使和s的值最小化的排列数组a。
You have array
a that contains all integers from
1 to
n twice. You can arbitrary permute any numbers in
a.
Let number
i be in positions
xi,yi (
xi<yi) in the permuted array
a. Let's define the value
di=yi-xi − the distance between the positions of the number
i. Permute the numbers in array
a to minimize the value of the sum
.
Output
Print
2n integers − the permuted array
a that minimizes the value of the sum
s.