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

22607번 - Tree Construction 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB114342.857%

문제

Consider a two-dimensional space with a set of points (xi, yi) that satisfy xi < xj and yi > yj for all i < j. We want to have them all connected by a directed tree whose edges go toward either right (x positive) or upward (y positive). The figure below shows an example tree.

Figure 1: An example tree

Write a program that finds a tree connecting all given points with the shortest total length of edges.

입력

The input begins with a line that contains an integer n (1 ≤ n ≤ 1000), the number of points. Then n lines follow. The i-th line contains two integers xi and yi (0 ≤ xi, yi ≤ 10000), which give the coordinates of the i-th point.

출력

Print the total length of edges in a line.

제한

예제 입력 1

5
1 5
2 4
3 3
4 2
5 1

예제 출력 1

12

예제 입력 2

1
10000 0

예제 출력 2

0

힌트

출처

Contest > ICPC Japanese Alumni Group > JAG Winter Contest > JAG Winter Contest 2010 J번

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

출처

대학교 대회

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

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