Laddu Problem DSA Learning

Please Tell me what is the problem in my code
#include<bits/stdc++.h>
using namespace std;
int laddus=0;

	string  cc;

int main(){
int t;
cin>>t;
while(t–){

	int a1;
	cin>>a1;
	string a;
	cin>>a;
	cc=a;
	while(a1--){
		string ss;
		cin>>ss;
		if(ss=="CONTEST_WON"){
			int ayush;
			cin>>ayush;
			if(ayush>20){
				laddus=laddus+300;
			}
			if(ayush<20){
				laddus=laddus+300+(20-ayush);
			}
		}
		if(ss=="TOP_CONTRIBUTOR"){
			laddus=laddus+300;
		}
		if(ss=="BUG_FOUND"){
			int anjali;
			cin>>anjali;
			if(anjali<=50){
				laddus=laddus+50;
			}if(anjali>=1000){
				laddus=laddus+1000;
			}if(anjali>50&&anjali<1000){
				laddus=laddus+anjali;
			}
		}
		if(ss=="CONTEST_HOSTED"){
			laddus=laddus+50;
		}
	}
	
	if(cc =="INDIAN"){
		cout<<laddus/200<<endl;
		laddus=0;
	}
	if(cc=="NON_INDIAN"){
		cout<<laddus/400<<endl;
	laddus=0;
	}}
}

Please share link of submission instead of copy pasting code to get reply from community.

3 Likes

A person who gets Contest_Won 20 are not getting 300 points in your code
if(ayush>20). ====>. if(ayush>=20).

Hi,

I am unable to find out why the code is failing. Can anyone help me identify the issue?

Solution Link : CodeChef: Practical coding for everyone

Hi dhanasekar_d. Check line 30 in your code. There lies your mistake. That’s how much of a hint you’ll get right now. Try to think about it and if you couldn’t find your mistake you can always get back to me.

Hi @guybeahm,

I realized the mistake in line 30, I was adding bonus (20) even if rank > 20.
I have update line: 30 and the solution was accepted.

laddus += (300 + 20 - (value <= 20 ? value : 20));

Thanks.

Hi,
Can anyone please check why my code is not able to pass all the test cases.
Thank You!
MY CODE

Which language

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

I have no idea why is it not working . Plz help?