F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Problem E. Find The Submatrix

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 86    Accepted Submission(s): 27


Problem Description
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.
 

Input
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.
 

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

Sample Input
2 5 1 0 1 3 -1 5 -1 -2 5 1 1 1 3 -1 5 -1 -2
 

Sample Output
7 8
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-17 01:12:09, Gzip enabled