The test file have N \leq 10^6. I have modified the statement.
Great, thanks for the rapid fix
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;
}
}
Can you tell me whats wrong?
That’s not a correct link to your code
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
)
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
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/viewsolution/40385455
I got right answer but it could not consider
help plz
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]
#include
using namespace std;
int withdraw;
double acc_amnt;
int main()
{
// your code goes here.
cin>>withdraw>>acc_amnt;
// If the Transaction SUCCESS.
if((withdraw%5 == 0) && (acc_amnt > (withdraw+0.50)))
{
acc_amnt = acc_amnt - (withdraw+0.500);
//cout<<acc_num;
printf("%.2f \n",acc_amnt);
}
// If the Transaction not SUCCESS.
if(withdraw%5 != 0 || acc_amnt < withdraw)
{
//cout<<acc_num;
printf("%.2f \n",acc_amnt);
}
return 0;
}
import java.util.Scanner;
class code_chef_1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double balance=120.0;
System.out.println(“Enter the amount to be withdrawn :”);
double withdrawal=sc.nextDouble();
if(((withdrawal+0.5)<=balance) && (withdrawal % 5 == 0))//successful transaction.
{
balance= balance-(withdrawal+0.5);
System.out.println(balance);
}
else if(((withdrawal+0.5)>balance) && (withdrawal % 5 == 0)) //insufficient funds.
System.out.println(balance);
else // incorrect withdrawal amount.
System.out.println(balance);
}
}