Maximum Rectangle Sum
Print the maximum sum over all non-empty axis-aligned sub-rectangles of an N×M integer grid.
Input: the first line has N and M; the next N lines have the grid rows.
Output: the maximum sub-rectangle sum.
Constraints:
- 1 ≤ N, M ≤ 500
- |values| ≤ 100
Sample Tests
Input 1
2 2 1 -2 -3 4
Output 1
4
Input 2
1 3 -1 -2 -3
Output 2
-1
Discussion (opens after you solve — no spoilers before)
No comments yet.