#P7626. [COCI 2011/2012 #1] MATRIX
[COCI 2011/2012 #1] MATRIX
Description
Given an matrix, find the square submatrix (i.e., with equal height and width) that has the maximum beauty value.
Define the beauty value of a matrix as follows: let be the sum of the numbers on the main diagonal of this matrix, and let be the sum of the numbers on the other diagonal. Then the beauty value is .
Input Format
The first line contains a positive integer .
The next lines each contain integers, describing the matrix.
Output Format
Output one integer on a single line, the maximum beauty value.
2
1 -2
4 5
4
3
1 2 3
4 5 6
7 8 9
0
3
-3 4 5
7 9 -2
1 0 -6
5
Hint
Constraints
For of the testdata, , and each matrix element .
Notes
The scoring of this problem follows the original COCI settings. The full score is .
This problem is translated from COCI2011-2012 CONTEST #1 T2 MATRIX.
Translated by ChatGPT 5
京公网安备 11011102002149号