How does the time limit work

Your program must read, process, and output the result for an input file within the specified time limit. An input file can contain a single test case or multiple test cases depending on the problem setter’s discretion. A test case will be of the format mentioned in the problem statement.

This means, if the input file contains multiple test cases, your code must complete ALL of these within time limit specified. If the time limit is 2 seconds, and there are 1000 test cases, your program shouldn’t be taking 2 second per test case - it needs to run all 1000 cases in under 2 seconds.

There can be multiple input test files too, each containing single or multiple test cases. The time limit is applied to each test file. That means If the time limit is 2 seconds, and there are 5 test files, your program could take upto 10 seconds to execute - it needs to run all 5 test files in under 10 seconds. However, it is to be noted, that the number of test files is not mentioned anywhere and is agnostic to the user.

Some programming languages are slower than others, and are thus given more time. Currently, Java and Python are allowed twice the time limit, while Ruby, PHP and Lisp are allowed to run for up to three times the time limit.

The hyperlinked blog post explains how the time limit will work for various languages.

4 Likes