Sorted Adjacent Differences
시간 제한1초메모리 제한1024 MB
주어진 배열을 재배열해 인접한 원소 사이 절댓값 차이가 감소하지 않도록 만든다. 조건을 만족하는 배열은 아무거나 출력해도 된다.
문제
You have array of numbers .
Rearrange these numbers to satisfy , where denotes absolute value of . It's always possible to find such rearrangement.
Note that all numbers in are not necessarily different. In other words, some numbers of may be same.
You have to answer independent test cases.
입력
The first line contains a single integer () --- the number of test cases.
The first line of each test case contains single integer () --- the length of array . It is guaranteed that the sum of values of over all test cases in the input does not exceed .
The second line of each test case contains integers ().
출력
For each test case, print the rearranged version of array which satisfies given condition. If there are multiple valid rearrangements, print any of them.
힌트
In the first test case, after given rearrangement, . There are other possible answers like "5 4 5 6 -2 8".
In the second test case, after given rearrangement, . There are other possible answers like "2 4 8 1".