RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
문제 ICPC00140

H. Hot Springs

스페셜 저지 — 출력을 사용자 정의 프로그램으로 검사하므로 여러 정답이 인정될 수 있습니다.
설명

Iceland is famous for its geothermal activity, which supplies the country with much of its electricity and heating. It is also a source of pleasure, in the form of hot springs.

Kalle is visiting one of Iceland's famous hot springs. It contains \(n\) pools of water, where the \(i\)th one has temperature \(t_i\). Although staying in one of the warmer pools for a long time sure is relaxing, Kalle is on a very tight schedule and just wants a quick dip in each of the pools. As you may know, the nicest thing about hot baths is the contrast between hot and cold. Therefore, to get the most out of his stay, Kalle wants to find an ordering of the pools so that the difference in temperature between subsequent pools is increasing.

Given a sequence of pool temperatures \(t_1, t_2, \dots, t_n\), rearrange them into a new sequence \(t'_1, t'_2, \dots, t'_n\) such that for all \(2 \leq i \leq n-1\) it holds that [
|t'{i-1} - t'_i| \leq |t'_i - t'|.
]

제약
입력 형식

The input consists of:
- One line with an integer \(n\) (\(2 \le n \leq 10^5\)), the number of pools.
- One line with \(n\) integers \(t_1, \ldots, t_n\) (\(-10^5 \leq t_i \leq 10^5\) for each \(i\)), the temperatures in each of the \(n\) pools.

출력 형식

Output a rearrangement of the sequence satisfying the given requirement. If no solution exists, output "impossible". If there are multiple valid solutions, you may output any one of them.

예제 1
입력
3
1 3 4
출력
4 3 1
예제 2
입력
6
0 0 1 -1 -6 3
출력
0 1 3 -1 -6 0
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NWERC 2020

평가 및 의견

H. Hot Springs

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

H. Hot Springs

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8