Help me in finding the problem in my program

,

Hi,
I am try to submit my solution on codechef for the first time but I am observing error with my submission.The code works fine on my machine but it is throwing error on codechef.
My submission- Solution: 48043679 | CodeChef
Kindly help me on this.

1 Like

Your implementation is wrong. Think about the problem more and also just because a pretest passed on your system doesn’t necessarily mean that it will get accepted. The submitted code is tested against a lot of test cases, not just a single one.

For your convenience I solved it in brute-force and optimized way.
Kindly check.

1- Bruteforce Solution

2- Optimized way