听说灌水区大佬多
  • 板块灌水区
  • 楼主wo_hen_la
  • 当前回复1
  • 已保存回复1
  • 发布时间2023/9/7 21:19
  • 上次更新2023/11/2 22:24:39
查看原帖
听说灌水区大佬多
794701
wo_hen_la楼主2023/9/7 21:19

P2706

https://www.luogu.com.cn/record/124047428

#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[305][305],b[305][305];
signed main()
{
	int n,ans=-1e18,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
			if(a[i][j]==0) a[i][j]=INT_MIN;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++) b[i][j]=b[i-1][j]+b[i][j-1]-b[i-1][j-1]+a[i][j];
	}
	for(int x=1;x<=n;x++){
		for(int y=1;y<=m;y++){
			for(int xx=x;xx<=n;xx++){
				for(int yy=y;yy<=m;yy++){
					ans=max(ans,b[xx][yy]+b[x-1][y-1]-b[xx][y-1]-b[x-1][yy]);
				}
			}
		}
	}
	cout<<ans;
	return 0;
}
2023/9/7 21:19
加载中...