Try the case Jan posted here:
http://online-judge.uva.es/board/viewtopic.php?t=7796
108 - Maximum Sum
Moderator: Board moderators
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 108-Maximum Sum WA
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 3
- Joined: Mon Jan 20, 2014 2:38 am
108 - Maximum Sum - WA
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.
Could you please check my code?
Thank you.
Code removed after AC.
Last edited by richard1017 on Wed Jan 22, 2014 1:33 am, edited 1 time in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 108 - Maximum Sum - WA
Print a newline char at the end of the line.
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 3
- Joined: Mon Jan 20, 2014 2:38 am
Re: 108 - Maximum Sum - WA
Thanks, Accepted!brianfry713 wrote:Print a newline char at the end of the line.
108 - Wrong answer
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.
![:(](./images/smilies/icon_frown.gif)
Please help.....
thanks in advance.
My code:
Removed after AC.
Last edited by vilash99 on Fri Feb 14, 2014 6:39 pm, edited 1 time in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 108 - Wrong answer
What is your algorithm? You can solve this in O(N ^ 5)
Check input and AC output for thousands of problems on uDebug!
Re: 108 - Wrong answer
Thanks, for suggestion.
I was trying to get O(N ^ 4) using Kadane algorithms.
Got AC in O(N^5)![:D](./images/smilies/icon_biggrin.gif)
I was trying to get O(N ^ 4) using Kadane algorithms.
Got AC in O(N^5)
![:D](./images/smilies/icon_biggrin.gif)
Re: 108 - Maximum Sum
my code work fine with random test but when i submit still WA
my code:
help please!
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);
}
Last edited by brianfry713 on Tue Oct 27, 2015 3:10 am, edited 1 time in total.
Reason: Added code block
Reason: Added code block
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 108 - Maximum Sum
Don't read from a file.
Check input and AC output for thousands of problems on uDebug!