Time limit exceed

I am getting the correct output when I run my code on coding blocks ide but when I try to submit the code it gives the error.

What is missing in this?
code: https://ide.codingblocks.com/s/366409

Hey @princeky4 are you getting TLE or WA in your submission? And also if you can specify test case number .

actually when I run my code in code editor with test case(given in question) then it runs fine and give the correct output. But when I try to run with no custom input then it gives me this error- runguard: warning: timelimit exceeded (wall time): aborting command runguard: warning: command terminated with signal 15

Hey @princeky4 the logic is absolutely correct. No doubt with it. What’s troubling in this code is while loop conditions and little bit formatting. Check this https://ide.codingblocks.com/s/366428. You will notice your mistake only in line 57 & 59 of this code. Rest the logic you have implemented is right :slight_smile: