#942
CUSKIJA
시간 제한
1s
메모리 제한
32MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%
문제
Rearrange the given array of integers so that the sum of two adjacent elements is never divisible by three.
입력
The first line contains an integer N (1 ≤ N ≤ 10 000), the number of elements in the array. The second line contains the elements of the array separated by single spaces. The elements will be positive integers less than 1 000 000.
출력
If any valid rearrangement exists, output it on a single line. Otherwise, output "impossible".
예제 입력 1
3
1 2 3
예제 출력 1
1 3 2
예제 입력 2
5
4 6 3 9 8
예제 출력 2
9 4 3 8 6
예제 입력 3
6
3 7 6 4 2 8
예제 출력 3
4 7 6 8 2 3
예제 입력 4
3
3 12 9
예제 출력 4
impossible
코드 제출
코드를 제출하려면 로그인이 필요합니다.
로그인내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.