+ 4
how to resolve the error of 'TIME LIMIT EXCEEDED'
C++
3 Antworten
+ 12
You shouldn't expect the virtual environment of the Code Playground to absorb complicated calculations. Perhaps simplify your code a bit.
+ 7
Optimize your code so it executes in less time, some loops may have to go or be optimised
+ 5
The inputs on which your code is run after submission are usually much much larger than the sample inputs. The time thats shown as 1.015 is not the actual run time of your code. It may be more than that but the execution of your code is stopped after the time limit
To avoid them, you can start with simple things like in C++ use scanf/printf instead of cin/cout, in Java use BufferedReader/PrintWriter instead of Scanner/System.out.
Now if you still get TLE, optimise your algorithm. Follow the constraints and check with the complexity of your solution. Usually normal systems can perform around 107107 calculations in a second. Make sure your code makes at the most that many calculations so that it can run under given time limit.