Maximum Submatrix Sum
시간 제한0.2초메모리 제한1024 MB
N 곱하기 M 행렬이 주어질 때, 빈 부분행렬을 포함한 모든 연속 직사각형 부분행렬의 합 중 최댓값을 구한다.
문제
You are given an matrix . Find the maximum sum of any subrectangular submatrix of this matrix.
Here, a subrectangular submatrix is defined as a contiguous submatrix formed by selecting any rectangular section of the given matrix , such that the submatrix includes all rows and columns between two specified pairs of indices and , where and , plus the case when the submatrix is empty.
입력
The first line of input contains two space-separated integers: and , denoting the size of the matrix. ( )
The next lines of input contain integers, where each line has space-separated integers, denoting the value of the matrix. Here, the -th integer of the -th line denotes . ()
출력
Output the maximum sum of any subrectangular submatrix on a single line.
힌트
(For Sogang students:) Note that this problem is an improvised version that matches the format of a problem in a general programming contest. While in the exam, the original scoring was:
- points for Subtask 1.
- points for Subtask 2.
- points for Subtask 3.
- points for Subtask 4.