View Code of Problem 182

#include <stdio.h>
#include "string.h"
int main()
{
    int m;
    int n,ss[1000][1000],max=0,dp[1000],temp[1000];
        scanf("%d",&m);
        scanf("%d",&n);
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                scanf("%d",&ss[i][j]);
        for(int i=0;i<n;i++)
        {
            memset(temp, 0, sizeof(temp));
            for(int j=i;j<n;j++)
            {
                for(int k=0;k<n;k++)
                    temp[k]+=ss[j][k];
                dp[0]=temp[0];
                for(int j=1;j<n;j++)
                {
                    dp[j]=dp[j-1]>0?dp[j-1]+temp[j]:temp[j];
                    max=max>dp[j]?max:dp[j];
                }
            }
        }
        printf("%d\n",max);

}

Double click to view unformatted code.


Back to problem 182