题意:给一个矩阵,里面有正负数,求子矩阵和的最大值
#include <iostream>
#include <cstdio>
#include <stdlib.h>
#include <memory.h>
using namespace std;
int s[][],dp[],n,temp[];
int main()
{
// freopen("in.txt","r",stdin);
cin>>n;
for(int i=;i<=n;i++)
for(int j=;j<=n;j++)
cin>>s[i][j];
int maxx = ;
for (int i=;i<=n;i++) //start from line i
{
memset(temp,,sizeof(temp));
for (int j=i;j<=n;j++) //end at line j
{
for (int k=;k<=n;k++)
{
temp[k]+=s[j][k];
if (temp[k]+dp[k-]>)
dp[k]=temp[k]+dp[k-];
else
dp[k]=;
if (maxx<dp[k])
maxx =dp[k];
}
}
}
cout << maxx << endl;
}