303196: CF622D. Optimal Number Permutation
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Optimal Number Permutation
题意翻译
给出一个数 $n$ . 现在有 $2n$ 个数,从 $1$ 到 $n$ 每个数的数量均为 $2$ . 定义 $s= \sum\limits_{i=1}^n (n-i) \times \left| d_i+i-n \right|$ . 设 $i$ 出现的位置为 $x_i$ , $y_i$ ( $x_i < y_i$ ) . 则 $d_i=y_i-x_i$ . 问如何排列使得这 $2n$ 个数最后求出的 $s$ 最小。题目描述
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 $ x_{i},y_{i} $ ( $ x_{i}<y_{i} $ ) in the permuted array $ a $ . Let's define the value $ d_{i}=y_{i}-x_{i} $ — the distance between the positions of the number $ i $ . Permute the numbers in array $ a $ to minimize the value of the sum ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF622D/22b9f04219f1da8748ed3cb58a6363dd566698ed.png).输入输出格式
输入格式
The only line contains integer $ n $ ( $ 1<=n<=5·10^{5} $ ).
输出格式
Print $ 2n $ integers — the permuted array $ a $ that minimizes the value of the sum $ s $ .
输入输出样例
输入样例 #1
2
输出样例 #1
1 1 2 2
输入样例 #2
1
输出样例 #2
1 1