hdu 1559(最大子矩阵)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1559

思路:感觉就是1081这题差不多,但就是加了一个限制条件。。。

View Code
 1 #include<iostream>
 2 #include<algorithm>
 3 const int N=1010;
 4 using namespace std;
 5 
 6 int map[N][N];
 7 
 8 int main(){
 9     int _case;
10     scanf("%d",&_case);
11     while(_case--){
12         int m,n,x,y;
13         scanf("%d%d%d%d",&m,&n,&x,&y);
14         for(int i=1;i<=m;i++){
15             for(int j=1;j<=n;j++){
16                 scanf("%d",&map[i][j]);
17             }
18         }
19         int ans=0;
20         for(int i=1;i<=m;i++){
21             for(int j=1;j<=n;j++){
22                 map[i][j]+=map[i][j-1]+map[i-1][j]-map[i-1][j-1];
23                 if(i>=x&&j>=y){
24                     int tmp=map[i][j]-map[i-x][j]-map[i][j-y]+map[i-x][j-y];
25                     if(tmp>ans)ans=tmp;
26                 }
27             }
28         }
29         printf("%d\n",ans);
30     }
31     return 0;
32 }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值