Problem E. Problem E. Find The Submatrix

时间限制 3000 ms   内存限制 512 MB

Little Q is searching for the submatrix with maximum sum in a matrix of $n$ rows and $m$ columns. The standard algorithm is too hard for him to understand, so he (and you) only considers those submatrixes with exactly $m$ columns.
It is much easier now. But Little Q always thinks the answer is too small. So he decides to reset no more than $A$ cells' value to $0$, and choose no more than $B$ disjoint submatrixes to achieve the maximum sum. Two submatrix are considered disjoint only if they do not share any common cell.
Please write a program to help Little Q find the maximum sum. Note that he can choose nothing so the answer is always non-negative.
 

输入数据

The first line of the input contains an integer $T(1\leq T\leq10)$, denoting the number of test cases.
In each test case, there are $4$ integers $n,m,A,B(1\leq n\leq 100,1\leq m\leq 3000,0\leq A\leq 10000,1\leq B\leq 3)$.
Each of the following $n$ lines contains $m$ integers, the $j$-th number on the $i$-th of these lines is $w_{i,j}(|w_{i,j}|\leq 10^9)$, denoting the value of each cell.
 

输出数据

For each test case, print a single line containing an integer, denoting the maximum sum.
 

样例输入

复制
2
5 1 0 1
3
-1
5
-1
-2
5 1 1 1
3
-1
5
-1
-2

样例输出

复制
7
8

提交

请先 登录

© 2025 FAQs Contact About