#P8343. [COCI 2021/2022 #6] Zemljište
[COCI 2021/2022 #6] Zemljište
Problem Description
There is a piece of land of size , and Matej wants to buy it. Each square on the land has a different price.
Let the sum of prices in a non-empty submatrix be . Then the value (weight) of this submatrix is . You need to find the submatrix with the minimum weight.
You only need to output the minimum weight.
Input Format
The first line contains four positive integers , , , and .
In the following lines, the -th line contains positive integers. The -th number is , which represents the price.
Output Format
Output one integer in a single line, which denotes the minimum weight among all non-empty submatrices.
2 2 10 10
1 3
4 1
2
3 2 3 4
1 9
1 1
8 1
3
3 4 5 3
1 1 1 1
9 6 7 6
8 1 9 7
2
Hint
Sample Explanation 2

As shown in the figure, the total price is , and the value of this land is .
Constraints
For of the testdata: .
For of the testdata: .
For of the testdata: , .
The score distribution of this problem is the same as COCI 2021-2022#6, with a full score of points.
Translated by ChatGPT 5