Page 16 of 16

Re: 108-Maximum Sum WA

Posted: Mon Jun 18, 2012 11:42 pm
by brianfry713

108 - Maximum Sum - WA

Posted: Mon Jan 20, 2014 9:57 pm
by richard1017
I test my code on several arrays and got the correct answer. However, the verdict says a WA.
Could you please check my code?
Thank you.

Code removed after AC.

Re: 108 - Maximum Sum - WA

Posted: Tue Jan 21, 2014 9:24 pm
by brianfry713
Print a newline char at the end of the line.

Re: 108 - Maximum Sum - WA

Posted: Wed Jan 22, 2014 1:33 am
by richard1017
brianfry713 wrote:Print a newline char at the end of the line.
Thanks, Accepted!

108 - Wrong answer

Posted: Thu Feb 13, 2014 5:56 pm
by vilash99
I used following code. Work fine for given input and my various test inputs. But WA :(
Please help.....
thanks in advance.
My code:

Removed after AC.

Re: 108 - Wrong answer

Posted: Thu Feb 13, 2014 11:14 pm
by brianfry713
What is your algorithm? You can solve this in O(N ^ 5)

Re: 108 - Wrong answer

Posted: Fri Feb 14, 2014 6:38 pm
by vilash99
Thanks, for suggestion.
I was trying to get O(N ^ 4) using Kadane algorithms.
Got AC in O(N^5) :D

Re: 108 - Maximum Sum

Posted: Fri Oct 23, 2015 12:23 pm
by cunbidun
my code work fine with random test but when i submit still WA
my code:

Code: Select all

#include<stdio.h>
#include<string.h>
int maxx(int a,int b){
    if(a>b) return a;
    else return b;
}

int main(){
     freopen("tongcn1.inp","r",stdin);
     //freopen("tongcn1.out","w",stdout);
    int n,a[125][127],i,j,s[127][127],max[127][127],maxt,k,ma,l   ;
     scanf("%d",&n);
    for(i=0;i<=n;i++)
            s[i][0]=0;
    for(j=0;j<=n;j++)
            s[0][j]=0;
    for(i=1;i<=n;i++)
            {
                for(j=1;j<=n;j++)
                {
                    scanf("%d",&a[i][j]);
                    s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+a[i][j];
                }
            }
    maxt=a[1][1];

    for(i=1;i<=n;i++)
            for(j=1;j<=n;j++)
            {
                for(l=0;l<i;l++)
                    for(k=0;k<j;k++)
                {


                        ma=s[i][j]-s[l][j]-s[i][k]+s[l][k];

                        if(ma>maxt) maxt=ma;
                }


            }
    printf("%d",maxt);
}
help please!

Re: 108 - Maximum Sum

Posted: Tue Oct 27, 2015 3:10 am
by brianfry713
Don't read from a file.