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

6124번 - Good Grass 다국어

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

문제

Bessie believes that her favorite pasture has a patch of very special grass that is the best grass on earth. She thinks it helps cows produce more milk.

Each of the cows has returned to her assigned grazing spot, which is at some point in a fully populated rectilinear grid. Consider the example on the left below where the number of rows, NR (3 <= NR <= 100) is 6 and the number of columns, NC (3 <= NC <= 100) is 5. The spots for cows are marked with a 'C'.

Bessie actually knows the milk production P_rc (1 <= P_rc <= 100) of each of the cows in the grid; the cows are tagged with the production number in the grid on the right, below.

 COLUMN COLUMN
 1 2 3 4 5 1 2 3 4 5
 +-------------- +--------------
 1| C C C C C 1| 5 6 7 4 6
 R 2| C C C C C R 2| 7 7 8 6 5
 O 3| C C C C C O 3| 9 9 8 3 5
 W 4| C C C C C W 4| 8 8 7 6 4
 5| C C C C C 5| 4 5 2 4 5
 6| C C C C C 6| 3 4 2 3 4

Bessie wants to find the location of the special grass. She intends to do this by finding the 3 x 3 grid of cows whose total milk production is the largest.

Find the 3 x 3 grid whose nine components sum to the greatest number and report the value of its upper left corner (first the row, then the column). In the grid above on the right, the largest sum is 71 found in the grid whose upper left corner (as depicted) is row 2, column 1.

If two 3 x 3 grids have the same sum, output the one whose row number is smallest. If more than one grid on that row has the same sum, output the one with the lowest column number.

입력

  • Line 1: Two space-separated integers: NR and NC
  • Lines 2..NR+1: Line r+1 contains NC space-separated integers that represent row r of the pasture's grid.

출력

  • Line 1: A single integer that is the greatest possible sum in a 3 x 3 square.
  • Line 2: Two space-separated integers that are respectively the row and column of the upper left corner of the 'best' 3 x 3 square grid.

제한

예제 입력 1

6 5
5 6 7 4 6
7 7 8 6 5
9 9 8 3 5
8 8 7 6 4
4 5 2 4 5
3 4 2 3 4

예제 출력 1

71
2 1

힌트

출처

Olympiad > USA Computing Olympiad > 2008-2009 Season > USACO US Open 2009 Contest > Bronze 3번

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

출처

대학교 대회

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

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