#P7160. 「dWoi R1」Sixth Monokuma's Son
「dWoi R1」Sixth Monokuma's Son
Description
Kibo's mechanical eye can scan an area. At row and column , it detects an abnormality value of .
Because Kibo is severely tortured by external forces, he can only lock onto one matrix ring to inspect. Kibo wants to ask you for help: he wants you to lock onto a matrix ring such that the sum of abnormality values of all positions in the matrix ring is maximized, the thicknesses of the top and bottom sides are , and the top row is the first row of the whole area, while the bottom row is the last row of the whole area. As for the left and right thicknesses, Kibo has no further constraints.
Input Format
The first line contains two integers , representing the size of the whole area.
Then lines follow, each containing integers , representing the abnormality value at each position.
Output Format
Output one integer in one line, representing the answer.
If it is impossible to choose a matrix ring that satisfies the requirements, output .
4 4
3 -4 2 -2
-5 3 -4 2
-1 3 -4 0
3 -3 3 4
8
1 2
11 45
-1
7 7
10 10 10 -100 11 11 11
10 10 10 -100 11 -100 11
10 10 10 -100 11 -100 11
10 10 10 -100 11 -100 11
10 10 10 -100 11 -100 11
10 10 10 -100 11 -100 11
10 10 10 -100 11 11 11
176
Hint
Sample Explanation
Explanation for Sample 1:
You can choose a matrix ring of the following form (but in fact the two solutions are the same, because the sum of all numbers in the first column is ):
++++ -+++
++-+ -+-+
++-+ -+-+
++++ -+++
Here, + means selected, and - means not selected.
For Sample 3, the provider is
Constraints and Notes
This problem uses bundled testdata.
- Subtask 1 (5 pts): or .
- Subtask 2 (5 pts): .
- Subtask 3 (40 pts): .
- Subtask 4 (50 pts): No special constraints.
For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号