#P6855. 「EZEC-4.5」走方格
「EZEC-4.5」走方格
Problem Description
There is an grid matrix. Little A starts from and goes to . He can only move down or right. The score he gets is the sum of the weights of the cells he passes through.
You are given the weight of each cell . You may change the weight of any one cell to . Find the minimum value of the maximum score Little A can obtain after the change.
Input Format
The first line contains two integers .
The next lines each contain integers .
Output Format
Output one integer, the minimum value of the maximum score Little A can obtain after the change.
2 2
3 3
6 4
9
3 3
1 1 1
2 1 2
3 1 1
6
Hint
This problem uses bundled testdata.
Sample Explanation
Sample 1: Change the weight of to . The path is -> -> , and the score is .
Sample 2: Change the weight of to . The path is -> -> -> -> , and the score is .
Constraints
.
.
$Subtask 3(30\ points): 1 \le n, m \le 2 \times 10^3$.
For of the testdata: , .
Translated by ChatGPT 5