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

5846번 - Tractor 다국어

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

문제

One of Farmer John's fields is particularly hilly, and he wants to purchase a new tractor to drive around on it. The field is described by an N x N grid of non-negative integer elevations (1 <= N <= 500). A tractor capable of moving from one grid cell to an adjacent cell (one step north, east, south, or west) of height difference D costs exactly D units of money.

FJ would like to pay enough for his tractor so that, starting from some grid cell in his field, he can successfully drive the tractor around to visit at least half the grid cells in the field (if the number of total cells in the field is odd, he wants to visit at least half the cells rounded up). Please help him compute the minimum cost necessary for buying a tractor capable of this task.

입력

  • Line 1: The value of N.
  • Lines 2..1+N: Each line contains N space-separated non-negative integers (each at most 1 million) specifying a row of FJ's field.

출력

  • Line 1: The minimum cost of a tractor that is capable of driving around at least half of FJ's field.

제한

예제 입력 1

5
0 0 0 3 3
0 0 0 0 3
0 9 9 3 3
9 9 9 3 3
9 9 9 9 3

예제 출력 1

3

힌트

Input Details

FJ's farm is a 5 x 5 grid. The elevations in the first row are 0, 0, 0, 3, and 3, and so on.

Output Details

A tractor of cost 3 is capable of moving between elevation 0 and elevation 3, so it can visit the block of cells at zero elevation as well as the block of cells at elevation 3. Together, these represent at least half of FJ's farm.

출처

Olympiad > USA Computing Olympiad > 2012-2013 Season > USACO February 2013 Contest > Silver 2번

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

출처

대학교 대회

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

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