0
已解决
屠永乐
高级守护
高级守护
#include<iostream> using namespace std; int n,m,a[301][301],s[301][301],f[301][301],f1[301][301],ans; int main() { 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]=-100000000; s[i][j]=s[i][j-1]+a[i][j]; } for(int i=1;i<=m;i++) for(int j=i+1;j<=m;j++) for(int k=1;k<=n;k++){ f1[i][j]=max(f1[i][j],0)+s[k][j]-s[k][i-1]; f[i][j]=max(f[i][j],f1[i][j]); } for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) ans=max(ans,f[i][j]); cout<<ans; return 0; }