#P1716. 双调序列
双调序列
Description
Students in the computer group often play small brain-teaser PK games. One day, a student invented a new sequence: the "Max-Min alternating sequence," defined as follows:
Suppose there are () integers (all within the long int range, i.e., ). The first number of the sequence is the maximum among the integers, the second number is the minimum, the third number is the second largest, the fourth number is the second smallest, and so on. Numbers that have been taken cannot be chosen again, proceeding until all numbers are used.
Please write a program to produce this sequence for the given integers.
Input Format
The first line contains an integer .
The next lines contain the integers described above, one integer per line.
Output Format
Output lines, each containing one integer, forming the required Max-Min alternating sequence.
5
10
-1
3
3
-9
10
-9
3
-1
3
Hint
For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号