Logo
(追記) (追記ここまで)

31159번 - Max Pair Matching 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB109554951.579%

문제

You are given 2ドルn$ pairs $(a_i, b_i)$ of integers. Consider a complete graph on 2ドルn$ vertices and define the weight of the edge $(ij)$ to be $w_{ij} = max(|a_i-a_j|, |a_i-b_j|, |b_i-a_j|, |b_i-b_j|)$.

Determine the maximum weight of the matching in this graph.

In other words, consider all ways to select $n$ edges of this graph such that no two chosen edges have a common endpoint. What is the maximum possible total weight of these edges?

입력

The first line of the input contains a single integer $n$ (1ドル \le n \le 10^5$).

The $i$-th of the next 2ドルn$ lines contain two integers $a_i$ and $b_i$ (0ドル \le a_i, b_i \le 10^9$).

출력

Print a single integer --- the maximum weight of the matching in this graph.

제한

예제 입력 1

2
0 10
7 7
9 4
2 15

예제 출력 1

18

노트

Adjacency matrix: $\begin{matrix}0 & 7 & 9 & 15 \\ 7 & 0 & 3 & 8 \\ 9 & 3 & 0 & 11 \\ 15 & 8 & 11 & 0 \end{matrix}$

출처

Contest > Open Cup > 2021/2022 Season > Stage 7: Grand Prix of Southeastern Europe N번

ICPC > Regionals > Europe > Southeastern European Regional Contest > SEERC 2021 G번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /