Does TLE mean that the answer was correct but only the program was slow?

I either need to make my program run faster, or need to think of a different algorithm all together. What does TLE really mean?

Shows 1.01 secs whereas the time limit is 1 second.

It shows 1.01 secs because your program execution is stopped once it exceeds the time limit. You cannot conclude whether output is right or wrong because your program might not have produced any output at all during the time(1 sec in this case) if pre-processing takes too much time or it might not have had the chance to run on a test case where it would have produced WA as execution was stopped.

TLE actually means that your program excedes the time limit for a particular test file. So, as soon as the time limit is exceeded the program stops executing and you don’t know whether your program gives AC or not.

So, best practice is to optimize your program as much as possible. Even, then it gives TLE, then go for different approach.

  • Time Limit Exceeded occurs normally when your algorithm is slower than the actual algo which you are required to use.

  • But in some cases ouput results in TLE when you use normal I/O instead of Fast I/O method.

Can you please answer this question?

Thanks. :slight_smile: