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

19043번 - Balance 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB67342354.762%

문제

We say that a matrix $A$ of size $N \times N$ is balanced if $A[i][j] + A[i + 1][j + 1] = A[i + 1][j] + A[i][j + 1]$ for all 1ドル \le i, j \le N - 1$.

You are given a matrix $A$ of size $N \times N$. Your task is to output another matrix $B$ of equal size such that $B$ is balanced and $B[i][j] \ge A[i][j]$ for all 1ドル \le i, j \le N$. Furthermore, your $B$ must have the minimum possible sum of entry values.

입력

The first line of input contains an integer $N,ドル the number of rows and columns of the matrix (1ドル \le N \le 50$).

Each of the following $N$ lines contains $N$ integers. Together they describe the matrix $A$. It is guaranteed that 0ドル \le A[i][j] \le 35,000円$ for all 1ドル \le i, j \le N$.

출력

On the first line, print the sum of the values of the balanced matrix $B$ you found. On the next $N$ lines, print the balanced matrix in the same format as given in the input.

Any output matrix that meets the constraints described in the statement will be accepted. The values of the output matrix are not constrained in any way (specifically, they may exceed the value 35ドル,000円$).

제한

예제 입력 1

4
1 1 1 1
1 1 1 1
1 1 1 0
1 1 1 1

예제 출력 1

16
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2017 > Day 2: UniBuc Contest A번

Contest > Open Cup > 2017/2018 Season > Stage 1: Grand Prix of Romania A번

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

출처

대학교 대회

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

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