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

34594번 - Move Stone 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB84292740.299%

문제

You are given an $n \times n$ grid. Each cell initially contains some number of stones, such that the total number of stones is exactly $n^2$.

In one move, you may take a single stone and move it to any other cell in the same row or the same column.

Your goal is to minimize the number of moves needed to make each cell contain exactly one stone.

입력

The first line contains an integer $n,ドル representing the size of the grid.

Followed by $n$ lines, the $i$-th of which contains $n$ integers, the $j$-th integer $a_{i,j}$ represents the number of stones in cell $(i, j)$.

출력

Output a single integer, the minimum number of moves required to make each cell contain exactly one stone.

제한

  • 1ドル ≤ n ≤ 500$
  • 0ドル ≤ a_{i,j} ≤ n^2$
  • The initial number of stones is exactly equal to the number of cells on the board.

예제 입력 1

3
0 1 2
0 2 2
1 1 0

예제 출력 1

3

예제 입력 2

5
1 2 4 0 1
2 0 0 2 0
1 4 1 0 1
2 0 0 0 0
1 2 0 1 0

예제 출력 2

11

노트

출처

ICPC > Regionals > Asia Pacific > Taiwan > Taiwan Online Programming Contest > TOPC 2025 K번

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

출처

대학교 대회

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

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