#K75487. Highest Score Permutation
Highest Score Permutation
Highest Score Permutation
Given a single integer (n), find a permutation of the numbers from 1 to (n) that achieves the highest possible score, where the score is defined as (\max_{1 \leq i < n} |a_i - a_{i+1}|).
The permutation is constructed by placing the largest available number and the smallest available number alternately to maximize the difference between consecutive elements. For example, if (n = 4), one valid solution is the permutation [4, 1, 3, 2] which gives a score of (|4-1| = 3).
inputFormat
The input consists of a single integer (n) (with (n \geq 1)), which represents the number of elements to be used in the permutation.
outputFormat
The output should contain two lines. The first line is the maximum score (an integer) achievable. The second line is the permutation of numbers from 1 to (n) (space-separated) that produces this score.## sample
2
1
2 1
</p>