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

6222번 - Building A New Barn 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB103282629.885%

문제

After scrimping and saving for years, Farmer John has decided to build a new barn. He wants the barn to be highly accessible, and he knows the coordinates of the grazing spots of all N (2 <= N <= 10,000) cows. Each grazing spot is at a point with integer coordinates (X_i, Y_i) (-10,000 <= X_i <= 10,000; -10,000 <= Y_i <= 10,000). The hungry cows never graze in spots that are horizontally or vertically adjacent.

The barn must be placed at integer coordinates and cannot be on any cow's grazing spot. The inconvenience of the barn for any cow is given the Manhattan distance formula |X-X_i|+|Y-Y_i|, where (X, Y) and (X_i, Y_i) are the coordinates of the barn and the cow's grazing spot, respectively. Where should the barn be constructed in order to minimize the sum of its inconvenience for all the cows?

입력

  • Line 1: A single integer: N
  • Lines 2..N+1: Line i+1 contains two space-separated integers which are the grazing location (X_i, Y_i) of cow i

출력

  • Line 1: Two space-separated integers: the minimum inconvenience for the barn and the number of spots on which Farmer John can build the barn to achieve this minimum.

제한

예제 입력 1

4
1 -3
0 1
-2 1
1 -1

예제 출력 1

10 4

힌트

The minimum inconvenience is 10, and there are 4 spots that Farmer John can build the farm to achieve this: (0, -1), (0, 0), (1, 0), and (1, 1).

출처

Olympiad > USA Computing Olympiad > 2006-2007 Season > USACO February 2007 Contest > Gold 1번

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

출처

대학교 대회

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

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