Page 3 of 3

Re: 10684 - The Jackpot

Posted: Fri Sep 27, 2013 11:36 pm
by brianfry713
You can solve each input set in O(N)

Re: 10684 - The Jackpot

Posted: Mon Mar 03, 2014 5:33 pm
by uDebug
Replying to follow the thread.

Re: 10684 - The jackpot

Posted: Tue May 26, 2015 12:08 am
by ksatori
Yes, I suppose this problem can be solved in O(n).

10684- WA

Posted: Sat Oct 24, 2015 5:30 am
by cunbidun
i dont understand why my code is WA

Code: Select all

#include<stdio.h>
#include<string.h>
int main(){
    freopen("10684uva.txt","r",stdin);
    long int a[1000],n,i=1,t[10000],max=-999999,j,cc;
    t[0]=0;
    while(scanf("%lld",&n)==1)
    {
        if(n==0)break;
        for(i=1;i<=n;i++){
            scanf("%d",&a[i]);
            t[i]=t[i-1]+a[i];
        }
    /*for(i=1;i<=n;i++)
        printf("%d ",t[i]);*/
    max=-1;
    if(n!=1)
    {

        for(i=2;i<=n;i++)
            for(j=0;j<i;j++)
            {
                cc=t[i]-t[j];
                if(cc>max) max=cc;
            }
        if(max>0) printf("The maximum winning streak is %d.\n",max);
        else printf("Losing streak.\n");
        max=-1;
    }
    else if(a[1]>0) printf("The maximum winning streak is %d.\n",max);
        else printf("Losing streak.\n");
    memset(a,0,n);
    memset(t,0,n);
    }

}
help me please

Re: 10684 - The jackpot

Posted: Tue Oct 27, 2015 3:26 am
by brianfry713
Don't read from a file.
Next time post in the existing thread.