60分,求调
查看原帖
60分,求调
739640
Handsome_Brother_Boy楼主2024/7/12 15:02
#include<bits/stdc++.h>
using namespace std;
long long n,a[101][101],s[101][101],maxn;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cin>>a[i][j];
			s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+a[i][j];
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			for(int x=i;x<=n;x++)
			{
				for(int y=j;y<=n;y++)
				{
					maxn=max(maxn,s[x][y]-s[i][y]-s[x][j]+s[i][j]);
				}
			}
		}
	}
	cout<<maxn;
	return 0;
 } 
2024/7/12 15:02
加载中...