#P9578. Minimizing Adjacent Sum Range in Permutations
Minimizing Adjacent Sum Range in Permutations
Minimizing Adjacent Sum Range in Permutations
Given a positive integer \(n\).
Define the function on a permutation \(\{x_1,x_2,\dots,x_n\}\) of \(\{1,2,\dots,n\}\) as:
[ f({x_n})=\max\limits_{1\le i\le n}(x_i+x_{(i\bmod n)+1})-\min\limits_{1\le i\le n}(x_i+x_{(i\bmod n)+1}) ]
Construct a permutation \(\{p_n\}\) of \(\{1,2,\dots,n\}\) such that for any permutation \(\{q_n\}\) it holds that \(f(\{p_n\})\le f(\{q_n\})\). Output the permutation \(\{p_n\}\).
inputFormat
The input consists of a single positive integer \(n\) (\(1\le n\le 10^5\)).
outputFormat
Output a permutation of \(\{1,2,\dots,n\}\) that minimizes \(f(\{p_n\})\). The permutation should be printed in one line with each number separated by a space. If there are multiple valid answers, any one will be accepted.
sample
3
1 3 2