Timelimit Issues

When, I try to submit a code with same logic in python it gives timelimit although it has 5 seconds timelimit. On the other hand when i submit the same logic in java it gets ACed within 2 seconds timelimit. How’s this possible, as python has been given 5 seconds but it gives TLE and the same logic ACed in java. However, it is written that since python is slow so they’ve given more timelimit, so they should’ve given timelimit that matches with the other languages.

1 Like

It can happen sometimes because python is much slower than other languages such as c, c++, and Java therefore its execution timelimit is 5 times the time limit given to c or c++. But still sometimes this much time is not enough. And most online judges only guarantee that a feasible solution only exists for c,c++,java.


If you want performance equivalent to java then submit using PYPY.
Actually default python is CPython and it first interprets code to c syntax then compile it.
But PYPY uses real time compiler. So it is fast.

1 Like

Ok, but then pypy3 has timelimit 2 seconds only… so no point if submitting in pypy3.

Ohk, then I will be doing in java. But python is addictive.

2 seconds are enough in PYPY like java as compared to 5 seconds in python According to my experience.

For me, if same code in python is giving TLE, it is definitely giving TLE in pypy3 too.
But the same logic in java getting ACed, it has happened with me twice.

That’s not true, for the same python code I got just 10 points while other subtasks got TLE but using PYPY3 I got 40 points. So, PYPY3 definitely runs python code way faster than python3.x