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

26054번 - Volcanoes 다국어

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

문제

Cimrman is going to visit all his artificial prairie volcanoes he has built in the previous few years. He is going to travel in his one-of-a-kind volcanology terrain vehicle.

Unfortunately, the vehicle has been currently damaged by an accidental meteorite strike. It can travel in only three possible directions, directly north, south or east. Cimrman decided this should not be a major problem, he is planning to organise his journey in such a way that the vehicle always travels in one of these three directions. Another peculiarity of the vehicle is that it can change its direction immediately.

Cimrman can start his journey at any point on the prairie. He wants the journey to be as short as possible.

입력

The first line of input contains one integer N (0 < N ≤ 105), the number of volcanoes. Each of the next N lines contains coordinates of one volcano. A volcano is represented as a point on a plane, first its x coordinate is given, then follows the y coordinate.

The point coordinates are two integer values in the range between −106 and 106 inclusive. Direction of positive x-coordinate corresponds to the eastward direction in the terrain.

출력

Print the length of a shortest journey which visits all the volcanoes. Assume the journey starts at the first volcano visit and ends at the last volcano visit.

제한

예제 입력 1

4
2 3
3 2
1 1
5 5

예제 출력 1

10

예제 입력 2

5
1 2
5 4
3 6
7 8
1 1

예제 출력 2

17

힌트

출처

ICPC > Regionals > Europe > Central European Regional Contest > CTU Open Contest > CTU Open Contest 2022 V번

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

출처

대학교 대회

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

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