시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 110 38 33 39.286%

문제

자연수로 이루어진 배열이 주어졌을 때, 수의 순서를 적절히 바꿔서 인접한 두 수의 합이 3으로 나누어 떨어지지 않는 배열을 만드는 프로그램을 작성하시오.

입력

첫째 줄에 배열의 크기 N이 주어진다. (1 ≤ N ≤ 10000)

둘째 줄에는 배열에 들어있는 수가 공백으로 구분되어 주어진다. 수는 1,000,000보다 작거나 같은 자연수이다.

출력

만약, 3으로 나누어 떨어지지 않게 배열을 만들 수 있다면 첫째 줄에 출력한다. 불가능하다면 -1을 출력한다.

예제 입력 1

3
1 2 3

예제 출력 1

2 3 1
W3sicHJvYmxlbV9pZCI6IjI5MzgiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiIzXHVjNzNjXHViODVjIFx1YjA5OFx1YjIwNFx1YzViNCBcdWI1YThcdWM1YjRcdWM5YzBcdWM5YzAgXHVjNTRhXHViMjk0IFx1YmMzMFx1YzVmNCIsImRlc2NyaXB0aW9uIjoiPHA+XHJcblx0XHVjNzkwXHVjNWYwXHVjMjE4XHViODVjIFx1Yzc3NFx1YjhlOFx1YzViNFx1YzljNCBcdWJjMzBcdWM1ZjRcdWM3NzQgXHVjOGZjXHVjNWI0XHVjODRjXHVjNzQ0IFx1YjU0YywgXHVjMjE4XHVjNzU4IFx1YzIxY1x1YzExY1x1Yjk3YyBcdWM4MDFcdWM4MDhcdWQ3ODggXHViYzE0XHVhZmQ0XHVjMTFjIFx1Yzc3OFx1YzgxMVx1ZDU1YyBcdWI0NTAgXHVjMjE4XHVjNzU4IFx1ZDU2OVx1Yzc3NCAzXHVjNzNjXHViODVjIFx1YjA5OFx1YjIwNFx1YzViNCBcdWI1YThcdWM1YjRcdWM5YzBcdWM5YzAgXHVjNTRhXHViMjk0IFx1YmMzMFx1YzVmNFx1Yzc0NCBcdWI5Y2NcdWI0ZGNcdWIyOTQgXHVkNTA0XHViODVjXHVhZGY4XHViN2E4XH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2009 > Contest #6 4번

  • 문제를 번역한 사람: baekjoon
  • 잘못된 조건을 찾은 사람: rdd6584