ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1146. Maximum Sum

why i get WA#10 ??? here is my code ..
Posted by fakhruddin 28 Apr 2010 12:26
#include<stdio.h>

long  mx,Matrix[1010][1010],i,j,k,y,sum,dim;

int main()
{

    while(scanf("%ld",&dim)==1)
    {
        mx=-99999;sum=0;
        for(i=0;i<101;i++)
          for(j=0;j<101;j++)
             Matrix[i][j]=0;

        for(i=1;i<=dim;i++)

            for( j = 1 ; j <= dim ; j++)

            {
                scanf("%ld", &Matrix[i][j]);

                Matrix[i][j]+= Matrix[i][j-1] + Matrix[i-1][j] - Matrix[i-1][j-1];

                if(mx < Matrix[i][j])
                    mx = Matrix[i][j];
            }

        for(i = 1; i <= dim ; i++)

            for(j = 1; j <= dim ; j++)

                for( y = 1; y < i ; y++)

                    for( k = 1 ; k < j ; k++)

                    {
                        sum = Matrix[i][j] - Matrix[i][k-1] - Matrix[y-1][j] + Matrix[y-1][k-1];

                        if(mx < sum)
                            mx = sum;
                        sum = 0;
                    }
        printf("%ld\n",mx);
    }
    return 0;
}





Edited by author 28.04.2010 16:00

Edited by author 28.04.2010 16:01

Edited by author 28.04.2010 16:01