UVA 10684- The Jackpot Solution

UVA 10684- The Jackpot  Solution


/*
uva id: shoaib05
Accepted Time:0.000
*/

#include<iostream>

using namespace std;

int input[10001],temp[10001];
int main()
{
int n,i,j,max;
while(cin>>n)
{
if(n==0)
break;
for(i=0;i<n;i++)
cin>>input[i];
max=temp[0]=input[0];
for(i=1;i<n;i++)
{
j=temp[i-1]+input[i];
if(j>input[i])
temp[i]=j;
else
temp[i]=input[i];
if(max<temp[i])
max=temp[i];
}
if(max>0)
cout<<"The maximum winning streak is "<<max<<"."<<endl;
else
cout<<"Losing streak."<<endl;
}
return 0;
}

Comments

Popular posts from this blog

uva 679 - Dropping Balls Solution

uva 481 - What Goes Up Solution

uva-10077 Solution --- The Stern-Brocot Number System