What does the execution time displayed for my submission mean?

I just submitted a solution for one of the problems on CodeChef. There is something called as execution time displayed after I got a corrected answer. What does it mean?

Codechef might test your code multiple times with different input files. If your code gives the correct answer within the time limit for each input file, the execution time displayed is the total of the time spent for each test case.

If your code does not pass an input file correctly, the time limit will be the total time of all input files, up to and including the one on which you fail, but not any further ones.

An example: suppose there are 5 input files, each with a time limit of 2 seconds. Your program runs for 1 second on each input file and produces the correct answer. The total time displayed will be 5 seconds - which is fine, because the time limit only applies to each input file individually.

On the other hand, suppose you get the first 2 input files correct in 1 second, the third one incorrect in 1.5 seconds. Your reported time will be 3.5 seconds.

People are often confused by a wrong answer in a very quick time changing to time limit exceeded. This is due to the first input file being small; a wrong answer means the time for large input files is not included.

5 Likes