You are not logged in. Please login at to post your questions!


Does Time limit exceeded or memory limit exceeded means our answer was correct?

Does time limit exceed means our answer was correct but time to run was more? I am getting time limit exceed error, Time to run shown as 1.01 seconds while under the question its shown as 1-2 seconds. Can someone explain?

asked 05 May '14, 01:09

miiitd7042075's gravatar image

accept rate: 0%

edited 12 May '14, 15:10

admin's gravatar image

0★admin ♦♦

It only means that your program ran for more time that it is allowed in the problem. However, it does mean that in the time limit that it ran, it didn't give any wrong answer, else the verdict would be WA. Either way, the number of test cases that your program solved in those few minutes may vary from 0 to <max t=""> -1.

To put it more clearly, It Does NOT mean that your program has the right logic. All it means is that it is taking too much time.

Sometimes your answer is right for the first few test cases, but the next few test cases give you TLE, and once you get rid of TLE, you get wrong answer again, which means for some test cases, your logic is wrong.


answered 05 May '14, 01:23

tacoder's gravatar image

accept rate: 18%

Lol codechef needs a better parser. <max t> turns to <max t="">

(05 May '14, 01:25) tacoder2★

Didn't knew i could use html tags in answers. Possible hack here?

(05 May '14, 01:28) tacoder2★

@miiitd7042075 Tle means for a given set of test cases you code is taking more time to execute or generate the output as decided bye the judges and also it does not means you answer was correct


answered 05 May '14, 01:20

saajan's gravatar image

accept rate: 3%

the best answer given by @admin in this thread.

i am posting answer here.

To understand Time Limit Exceeded(TLE), understanding how the online judge works will help. The online judge allocates resources like memory and CPU for evaluating every submission. However, to ensure that your submission does not keep running for an infinite time, the online judge has to stop your submission from running after a particular time period. This time period is actually decided by the problem setter and is given as one of the inputs to the online judge. Once the submission program runs for time period the judge system issues a system kill command to the program execution and assigns TLE result to the submission.

The most common reason that you would get a TLE is because your program is too slow. If a problem tells you that N <= 100000, and your program has nested loops each which go up to N, your program will never be fast enough. Read the bounds in the input carefully before writing your program, and try to figure out which inputs will cause your program to run the slowest.

The second most common cause of TLE is that your method of reading input and writing output is too slow. In Java, do not use a Scanner; use a BufferedReader instead. In C++, do not use cin/cout - use scanf and printf instead.

In Python, you could try speeding up your solutions by adding the following two lines to the start of your file:

import psyco


To see if your method of reading input is fast enough, try solving the Enormous Input Test problem. If you get time limit exceeded, try another method of reading input.

Finally, you may have tested your code on all sorts of large inputs and are sure your code will run inside the time limit. However, CodeChef's judge may be slower than your computer. It is common for a program to take 2-3 times as long on CodeChef as it does on your computer. The time limits are all attainable(tested by our problem tester), so you will just need to come up with a way of making your algorithm


answered 05 May '14, 01:51

antim_patel's gravatar image

accept rate: 23%

No. TLE does not mean your answer was correct. The judge kills the process as soon as the time taken by it exceeds maximum time limit. So, in case of maximum time limit 't' along with TLE, you will get t + s as time taken by your program where s ~ 0.01 .


answered 05 May '14, 01:18

ringo1611's gravatar image

accept rate: 0%

edited 05 May '14, 01:24

I don't think program is killed too soon. I coded in Java and its about 7 times as slow as in C. They constantly gave me TLE error with running time between 7.3 to 7.5 sec, while in C it was between 1.01 to 1.05 sec.

(07 May '14, 13:22) miiitd70420752★

Umm well it actually only means that your program ran for more time that it is allowed in the problem as you can see in the answer reviews. So technically in some cases your answers are right in some they are not.


answered 24 Feb '17, 11:18

adelegoodwin's gravatar image

accept rate: 0%

Looking for a PRO Services in Qatar Checkout BBMs


answered 30 Mar, 13:26

rehmaan123's gravatar image

accept rate: 0%

Your program will not run successfully even accepting sample inputs. I think you should work on an algorithm and design it accordingly. Then implement it. assignment service


answered 05 May, 12:36

selinajasmin00's gravatar image

accept rate: 0%

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 05 May '14, 01:09

question was seen: 6,051 times

last updated: 05 May, 12:36