Wrong answer although online IDE is giving the correct answer for custom input.

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

What is exactly going wrong in this code that is making it wrong?

Some custom input test cases doesn’t guarantee it will work on all test cases.It means the solutions is missing some particular test cases
Also during the duration of contest it is not ethical to ask about the question in the forum.For any queries related to it you ask it the comment section.
Best of Luck

1 Like