Recently the Educational round 144 , Python Code for D question that used iterative approach Dynamic programming resulted in TLE.
However C++ code for the same passed in 170 ms
Python Code — https://p.ip.fi/hwgL C++ Code — https://p.ip.fi/Jsdm
vovuh , adedalic, please look into the matter.
This is probably the 3rd or 4th-time python gave TLE but C++ did not. Why at all keep python a language option if not tested properly
Auto comment: topic has been updated by tan_delhi (previous revision, new revision, compare).
Hey. See my last submission. Python is not very fast sometimes, but if you copy Fast input-output, it can pass (like 1949ms/2000ms). Of course use Pypy3-64
Thanks bro, everyday is a new experiment with python
All C++ enjoyers after reading this post are like
You can try changing -math.inf to float("-inf") and use PyPy 3-64 over PyPy 3
C++ is much faster than Python (that is why many programmer prefers using C++ over Python). See this, I use the same algorithm for this problem and uhhh... C++ is about 15 times faster.
So C++ is worth learning.
I slightly altered your code and now it passes. You used fast input, but didn't use fast output, calling print function multiple times is slow af. Also not quite sure if imporing full module instead of a few functions will slow down your code, but I have a feeling that it does. Here is the submission 195542299