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.

1 Like

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.

3 Likes

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.

1 Like
  • 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.

1 Like

Can you please answer this question?

http://discuss.codechef.com/questions/22303/scanf-and-cin-giving-different-outputs-please-help

1 Like

Thanks. :slight_smile:

This post was flagged by the community and is temporarily hidden.

How to use fast I/0 method? Can you help in that?

If you use C++ you can just use these two lines inside your main

ios_base::sync_with_stdio(false);
cin.tie(NULL);

See this for more info

1 Like

When a question is created a Time Limit is set which is set by the tester. Your source code is expected to finish within the given time limit (e.g. 1 sec in your problem).
When generating output against your submitted source code exceeded the predefined time limit, OJ immediately issues kill command to your code and outputs TLE verdict.
This is the reason why it shows 1.01 sec. because your code can’t be allowed to run more than the time limit.
So, your code might be correct or it might also not be. It can’t be concluded.
Happy Coding (_)

1 Like