40WA求解

P1719 最大加权矩形

rain_forest @ 2018-10-27 23:45:25

#include<bits/stdc++.h>
using namespace std;
int f[121][121],a[121][121];
int main()
{
//  freopen("ttt.in","r",stdin);
    //freopen(".out","w",stdout);
    int n;
    scanf("%d",&n);
    memset(f,0,sizeof(f));
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++){
            scanf("%d",a[i]+j);
            f[i][j]=f[i-1][j]+f[i][j-1]-f[i-1][j-1]+a[i][j];
//          printf("%d ",f[i][j]);
        }
    int ans=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=i;j++)
            for(int I=1;I<=i;I++)
                for(int J=1;J<=j;J++)
                    ans=max(ans,f[i][j]-f[I-1][j]-f[i][J-1]+f[I-1][J-1]);
    printf("%d\n",ans);
    return 0;
}

by rain_forest @ 2018-10-27 23:49:42

求大佬解惑注意不是TLE,是WA!!!


by rain_forest @ 2018-10-28 00:38:44

不用管我了,我已经A了我是智障


|