10684 - The Jackpot

All about problems in Volume CVI. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Postby mamun » Mon Jan 02, 2006 4:47 pm

Declare check[][] and money[] globally or as static in main().
mamun
A great helper
 
Posts: 286
Joined: Mon Oct 03, 2005 1:54 pm
Location: Bangladesh

Postby helloneo » Mon Jan 02, 2006 5:00 pm

the array check[][] is too big..~
helloneo
Guru
 
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

CE...

Postby Obaida » 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...
Code: Select all
Thank you mf I was wrong in thinking..
AC.... :wink:
Last edited by Obaida on Thu Mar 27, 2008 11:59 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.
Obaida
A great helper
 
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

WA...

Postby Obaida » 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]
try_try_try_try_&&&_try@try.com
This may be the address of success.
Obaida
A great helper
 
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 10684 - The Jackpot

Postby rajib_sust » 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).


i am not understand this two line of code. what do u mean by win win strategy.

rajib
sust
life is beautiful like coding
rajib_sust
New poster
 
Posts: 16
Joined: Sun Mar 02, 2008 10:34 am
Location: SUST , Sylhet, Bangladesh

Re: 10684 - The Jackpot

Postby Skt » 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[i];
s[0] = 0;
FOR(i,1,n+1)
s[i] = MAX(s[i-1]+arr[i],arr[i]);
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
Skt
New poster
 
Posts: 5
Joined: Wed Oct 29, 2008 2:55 pm

Re: 10684 - The Jackpot

Postby mathgirl » 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 ?

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;
}
mathgirl
New poster
 
Posts: 36
Joined: Tue Apr 24, 2012 6:20 pm

Re: 10684 - The Jackpot

Postby brianfry713 » 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.
brianfry713
Guru
 
Posts: 1742
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10684 - The Jackpot

Postby tamimcsedu19 » 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");
    }

}
tamimcsedu19
New poster
 
Posts: 3
Joined: Fri Mar 01, 2013 6:17 pm

Re: 10684 - The Jackpot

Postby brianfry713 » Mon Apr 22, 2013 11:44 pm

Try input:
1
1
0
brianfry713
Guru
 
Posts: 1742
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Previous

Return to Volume CVI

Who is online

Users browsing this forum: No registered users and 1 guest

cron