| 2025 GUC Winter Camp |
|---|
| Finished |
You are given an integer $$$n$$$. Your task is to construct a permutation $$$p$$$ of the integers from $$$1$$$ to $$$n$$$.
Let's define the cost of any subarray $$$p[i \ldots j]$$$ (the elements $$$p_i, p_{i+1}, \ldots, p_j$$$) as: $$$$$$cost(i, j) = \max(p_i, \ldots, p_j) - \min(p_i, \ldots, p_j) - (j - i + 1)$$$$$$
The total cost of the permutation $$$p$$$ is the sum of costs over all possible subarrays: $$$$$$TotalCost(p) = \sum_{1 \le i \le j \le n} cost(i, j)$$$$$$
You must find a permutation $$$p$$$ that minimizes this $$$TotalCost(p)$$$. If there are multiple such permutations that achieve the minimum possible cost, you must output the one which is lexicographically maximum.
The first and only line of input contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$).
Output $$$n$$$ space-separated integers, representing the permutation $$$p_1, p_2, \ldots, p_n$$$ that minimizes the total cost and is lexicographically maximum among all optimal permutations.
1
1
2
2 1
| Name |
|---|


