Why do I get Wrong Answer?

,

Shit! After I understand it and post my code for help, I saw @ssjgz already post this.

2 Likes

Thank you so much…its working after i removed the constraints…

3 Likes

The test file have N \leq 10^6. I have modified the statement. :slight_smile:

2 Likes

Great, thanks for the rapid fix :slight_smile:

1 Like

Lead game problem
Can you help me out here with whats wrong…Wrong answer error
#include
using namespace std;
int main()
{
int T;
int alead=0,blead=0;
cin>>T;
if (T<=1000)
{
for (int i=0; i<T; i++)
{
int ascore,bscore;
cin>>ascore>>bscore;
if (ascore>bscore)
{
if((ascore-bscore)>alead)
alead=ascore-bscore;
}
else if (bscore>ascore)
{
if((bscore-ascore)>blead)
blead=bscore-ascore;
}
}
if(alead>blead)
cout<<1<<" “<<alead;
else if(blead>alead)
cout<<2<<” "<<blead;
}
}

Copy-and-paste:

Please either format your code or (better!) link to your submission :slight_smile:

https://www.codechef.com/viewsolution/30076934

1 Like

Thanks - it fails on the same testcase as this guy’s.

1 Like

https://www.codechef.com/submit/TLG
Can you tell me whats wrong?

That’s not a correct link to your code :slight_smile:

1 Like

https://www.codechef.com/viewsolution/30367056

1 Like

This gives the wrong answer for the testcase:

9
3 66
3 20
2 60
2 1
1 69
3 66
3 1
3 72
1 54

(the answer should be

2 388

)

1 Like

why 388 aint should be 338, check the test case once please.

In round 1 player 1 scored: 3 and player 2 scored: 66
The cumulative scores are now - player 1: 3; player 2: 66

New best lead: player 2 has a lead of 63 over player 1

In round 2 player 1 scored: 3 and player 2 scored: 20
The cumulative scores are now - player 1: 6; player 2: 86

New best lead: player 2 has a lead of 80 over player 1

In round 3 player 1 scored: 2 and player 2 scored: 60
The cumulative scores are now - player 1: 8; player 2: 146

New best lead: player 2 has a lead of 138 over player 1

In round 4 player 1 scored: 2 and player 2 scored: 1
The cumulative scores are now - player 1: 10; player 2: 147

In round 5 player 1 scored: 1 and player 2 scored: 69
The cumulative scores are now - player 1: 11; player 2: 216

New best lead: player 2 has a lead of 205 over player 1

In round 6 player 1 scored: 3 and player 2 scored: 66
The cumulative scores are now - player 1: 14; player 2: 282

New best lead: player 2 has a lead of 268 over player 1

In round 7 player 1 scored: 3 and player 2 scored: 1
The cumulative scores are now - player 1: 17; player 2: 283

In round 8 player 1 scored: 3 and player 2 scored: 72
The cumulative scores are now - player 1: 20; player 2: 355

New best lead: player 2 has a lead of 335 over player 1

In round 9 player 1 scored: 1 and player 2 scored: 54
The cumulative scores are now - player 1: 21; player 2: 409

New best lead: player 2 has a lead of 388 over player 1

Final winner/ lead: 
2 388
2 Likes

why codechef is showing wrong answer.
https://www.codechef.com/viewsolution/30548979

Can someone help me with this, please?
I get the same results as in the example but it still shows wrong answer :-

https://www.codechef.com/submit/SWPDGT

https://www.codechef.com/viewsolution/40385455
I got right answer but it could not consider
help plz

#include

using namespace std;

float bank(int wid, float bal);

int main(void)
{
int wid;
float bal;
cin >> wid >> bal;
float x = bank(wid, bal);
printf("%.2f", x);
return 0;
}

float bank(int wid, float bal)
{
if (wid >= bal)
{
return bal;
}
else
{
if (wid % 5 == 0)
{
return (bal - wid - 0.5);
}

    else if (wid % 5 != 0)
    {
        return bal;
    }
}

}

//this code is running properly and is satisfying all the test cases still when I try to submit it shows the wrong answer. the question is ATM and the Problem Code: HS08TEST

You are ignoring one more case.
What happens when the test case is : 100 100 ?
Your code will print YES even though the answer is NO . I hope you get the point.

#include <stdio.h>

int main() {
// your code goes here
int i,T;
scanf("%d",&T);
for(i=0;i<T;i++)
{
int N,d,m,sum=0,n;
scanf("%d",&d);
N=d;
n=N+1;
while(n>0)
{

        m=n%10;
        sum=sum+m;  
        n=n/10;
    }
    printf("%d",sum);
}
return 0;

}

please tell me why i get wrong answer… Problem Code:[ICPC16C]