#C7374. Minimize Maximum Travel Distance
Minimize Maximum Travel Distance
Minimize Maximum Travel Distance
You are given a single integer n
representing tools numbered from 1 to n
. Your task is to arrange these tools in a sequence so that the maximum distance any tool has to travel from the starting position (which is the position of tool 1) is minimized.
The optimal strategy is to start with tool 1 and then alternately select the smallest and largest remaining tools. This creates a balanced arrangement. In mathematical terms, if the resulting permutation is \(p_1, p_2, \dots, p_n\), the maximum travel distance (from the starting position at tool 1) can be represented as:
[ D = \max_{1 \leq i \leq n} \left|p_i - p_1\right| ]
Though the distance formula is given above, the key is to follow the alternating selection scheme to produce the desired result.
inputFormat
The input consists of a single integer n
(1 \le n \le 10^5
), which represents the number of tools.
outputFormat
Output the arranged sequence of tools as space-separated integers on one line.
## sample1
1