60分求助
查看原帖
60分求助
975589
BestCat2023楼主2023/10/2 10:12

记录:https://www.luogu.com.cn/record/126990094

代码:

#include<iostream>
using namespace std;
typedef long long ll;
const int N=125;
int n;
int a[N][N],s[N][N];
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];
        }
    }
    int mx=-1;
    for(int x1=1;x1<=n;x1++){
        for(int y1=1;y1<=n;y1++){
            for(int x2=1;x2<=n;x2++){
                for(int y2=1;y2<=n;y2++){
                    mx=max(mx,s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1]);
                }
            }
        }
    }
    cout<<mx;
    return 0;
}

求大佬指点

2023/10/2 10:12
加载中...