Getting wrong answer in FFL April Lunchtime

https://www.codechef.com/viewsolution/32272996
what is the mistake in this logic ? Can anyone help?

Bro as per the constraints, the value of N can be 1 also.
So think about it, like if there were no ā€œ0ā€™sā€ or no ā€œ1ā€™sā€ in the array, your code would give wrong ans.

Consider following test-cases:

2
1 100
2
1
1 85
7
0

Your Code Output:

yes
yes

Correct Output:

no
no

Fix:
Your code is giving WA because of the overflow in mnF + mnD because you have initialised it with INT_MAX rather initialise it with 101 according to the constraints or if you want to go with INT_MAX then change the data-type of tot to long long int rather that int.

// int mnF = INT_MAX, mnD = INT_MAX;
int mnF = 101, mnD = 101;

Updated Code (AC): CodeChef: Practical coding for everyone

2 Likes

thankyou bro, I got my mistake now. :slight_smile: