Posted:

**Mon Jan 02, 2006 4:47 pm**Declare check[][] and money[] globally or as static in main().

Page **2** of **3**

Posted: **Mon Jan 02, 2006 4:47 pm**

Declare check[][] and money[] globally or as static in main().

Posted: **Mon Jan 02, 2006 5:00 pm**

the array check[][] is too big..~

Posted: **Sun Mar 23, 2008 8:12 am**

Is there any reason to have CE...! This is crazy....

Any one could debug my program and suggest me that it's ok or not...

Any one could debug my program and suggest me that it's ok or not...

Code: Select all

```
Thank you mf I was wrong in thinking..
AC.... :wink:
```

Posted: **Sun Mar 23, 2008 8:30 am**

Ok... I traced why CE... I was using i in both loop... But now it is getting WA.... Help me...[/code]

Posted: **Fri Aug 29, 2008 10:40 am**

Code: Select all

```
he can identify patterns of consecutive wins and elaborate a win-win strategy.
A bet is an amount of money and is either winning (and this is recorded as a positive value).
```

rajib

sust

Posted: **Tue Sep 15, 2009 7:30 pm**

well this is how my code looks like if i have found it to be coorect its the maximum sum and used dp for it can any one plz tell my errors or provide me with test case which would help me realize my error

long long i,j,arr[1001];

while(cin>>n && n!=0)

{

long long s[1001] = {0};

FOR(i,1,n+1)

cin>>arr*;*

s[0] = 0;

FOR(i,1,n+1)

s* = MAX(s[i-1]+arr**,arr**); *

if(s[i-1]>0)

cout<<"The maximum winning streak is "<<s[i-1]<<"."<<endl;

else

cout<<"Losing streak."<<endl;

}

** MAX & FOR are simple macros that i have used

long long i,j,arr[1001];

while(cin>>n && n!=0)

{

long long s[1001] = {0};

FOR(i,1,n+1)

cin>>arr

s[0] = 0;

FOR(i,1,n+1)

s

if(s[i-1]>0)

cout<<"The maximum winning streak is "<<s[i-1]<<"."<<endl;

else

cout<<"Losing streak."<<endl;

}

** MAX & FOR are simple macros that i have used

Posted: **Sat May 19, 2012 12:25 pm**

Is this problem maximum consecutive sum or maximum sum ? I have tried both, but getting WA.

For example,

5 5 -1 5 5

Is the answer 10 or 19 ?

For example,

5 5 -1 5 5

Is the answer 10 or 19 ?

Code: Select all

```
#include<stdio.h>
#include<vector>
using namespace std;
int main()
{
int n,re;
re = scanf("%d",&n);
while(n)
{
vector<int> input;
int a;
for(int j=1;j<=n;j++)
{
scanf("%ld",&a);
input.push_back(a);
}
int sum = 0,maxs = 0;
int i = 0,j;
while(i<input.size())
{
sum = 0;
j = i;
while(j<input.size())
{
sum = sum + input[j];
j++;
maxs = max(sum,maxs);
}
i++;
}
if(maxs>0)
printf("The maximum winning streak is %d.\n",maxs);
else
printf("Losing streak.\n");
re = scanf("%d",&n);
}
return 0;
}
```

Posted: **Tue May 22, 2012 2:47 am**

maximum possible gain out of a sequence of consecutive bets.

19.

Use %d when reading an int in scanf.

19.

Use %d when reading an int in scanf.

Posted: **Sat Apr 20, 2013 7:21 pm**

Why WA, where am I wrong?

Code: Select all

```
#include <stdio.h>
#include <iostream>
#include <iterator>
using namespace std;
int main()
{
int n;
while(scanf("%d",&n)&&n!=0){
std::istream_iterator<int> int_it(cin),end;
int sum=*int_it++;
for(int i=2;i<n;++i)
{
sum+=*int_it++;
if(sum<0)
sum=0;
}
sum+=*int_it;
if(sum>0)
printf("The maximum winning streak is %d.\n",sum);
else
printf("Losing streak.\n");
}
}
```

Posted: **Mon Apr 22, 2013 11:44 pm**

Try input:

1

1

0

1

1

0

Posted: **Sat Jun 22, 2013 4:38 am**

Hi,

today I made this problem and I found something interesting.

I sent my code and while it was in queue I realized that my code failed for this case:

1

1

0

So I sent it again, but with the correction.

The funny thing is that when I checked I had the two submissions accepted.

The firstone's output was:

today I made this problem and I found something interesting.

I sent my code and while it was in queue I realized that my code failed for this case:

1

1

0

So I sent it again, but with the correction.

The funny thing is that when I checked I had the two submissions accepted.

The firstone's output was:

and the second's:Losing streak.

How could be this possible?The maximum winning streak is 1.

Posted: **Sat Jun 22, 2013 6:55 am**

The second is correct. The judge can't test all possible inputs, so whatever was wrong with your code isn't tested by the judge's I/O.

Posted: **Wed Aug 14, 2013 3:17 pm**

Code: Select all

```
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdio>
#include<stdlib.h>
#include <queue>
#include <stack>
#include<string>
#include<list>
#include<map>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
int n,x;
long long sum,max;
while(scanf("%d",&n) == 1 && n)
{
max = -1;
sum = 0;
while(n--)
{
scanf("%d",&x);
if(x < 0)
{
if(max < sum)
max = sum;
sum =0;
}
else
sum = sum + x;
}
if(max < sum)
max = sum;
if(max > 0)
printf("The maximum winning streak is %lld.\n",max);
else
printf("Losing streak.\n");
}
return 0;
}
```

Posted: **Wed Aug 14, 2013 3:28 pm**

try this

**input:**
**output:**

5

12 -4

-3 4

9

0

The maximum winning streak is 18.

Posted: **Thu Sep 26, 2013 5:14 pm**

I got TLE with this code but when I tried n=10000 it work faster than 3s.

Please help me improve my code.

Please help me improve my code.

Code: Select all

```
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
int sum,n[10005],tmp[10005],big;
while(1)
{
scanf("%d",&sum);
if(sum==0)
break;
for(int i=0;i<sum;i++)
{
scanf("%d",&n[i]);
tmp[i]=n[i];
}
big=*max_element(n,n+sum);
for(int i=1;i<sum;i++)
{
for(int j=0;j<sum-i;j++)
{
tmp[j]+=n[j+i];
if(big<tmp[j])
big=tmp[j];
}
}
if(big<1)
printf("Losing streak.\n");
else
printf("The maximum winning streak is %d.\n",big);
}
}
```