最大子矩阵
Time Limit: 30000/10000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3264 Accepted Submission(s): 1648
1 4 5 2 2 3 361 649 676 588 992 762 156 993 169 662 34 638 89 543 525 165 254 809 280
2474/* 挺好的,没想到这么做。。dp[i][j]数组表示(1,1)到(i,j)的和的总和 加油!!! Time:2015-4-6 20:33 */ #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int MAX=1000+10; const int INF=0x3f3f3f3f; int dp[MAX][MAX]; int main(){ int T; int n,m,a,b,val; scanf("%d",&T); while(T--){ int maxV=-INF; scanf("%d%d%d%d",&n,&m,&a,&b); for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ scanf("%d",&val); dp[i][j]=dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1]+val; if(i>=a&&j>=b) maxV=max(maxV,dp[i][j]-dp[i-a][j]-dp[i][j-b]+dp[i-a][j-b]); } } printf("%d\n",maxV); } return 0; }
2万+




被折叠的 条评论
为什么被折叠?



