Information regarding time limit exceeded

Suppose I have a program which after submission shows time limit exceeded. Does this mean that it has been able to clear all the test cases but could not do so within the required time OR that before it could complete all the test cases the time limit got exceeded?

If it’s the second case then that means that my code could give wrong answer even after I optimize it because my logic is incorrect and if it’s the first case then that means that my current logic is correct but it could be optimized.

Was just curious.

@vasuchat, if you get TLE verdict it means that your program didn’t finish running before the time specified. And it probably means that the judge couldn’t even test your output to see if it’s correct. So it could go both ways, your code could be correct or wrong but is not finishing in time. The same thing can happen with WA verdict, if your code can give Wrong Answer and even after correcting it you can get Time Limit Exceeded. You should focus on the verdict you’re getting. Don’t assume anything else besides the verdict you’re getting. TLE means Time Limit Exceeded, it doesn’t mean Time Limit Exceeded with/without Correct Answer. WA means Wrong Answer, it doesn’t mean Wrong Answer with/without Time Limit Exceeded. Don’t get ahead of yourself.

1 Like

It is the second case that is : before it could complete all the test cases the time limit got exceeded . So yes you are right your code could give wrong answer even after you optimize it because your logic is incorrect or it could also give AC if your logic is right.