In the time limits based on programming language page, it says that Python has a 3X time multiplier. I suspect this multiplier isn’t being applied to Python 3 submissions, as a submission of mine in Python 3 was getting the time limit exceeded error, and when submitting instead in Python 2 with essentially exactly the same code (slightly different syntax for the print statement in v3 than in v2) it passed.
My submissions are available here:
Can anyone confirm or refute my suspicision?
1 Like
you seem to be right.
the other amazing thing is the following one.
you code : AC in PYTH in 7.14 s.
http://www.codechef.com/viewsolution/994487
def zeros(num):
total = 0
while num >= 5:
num = num // 5
total += num
return total
for i in range(int(input())):
print zeros(int(input()))
my code : AC in PYTH in 3.05 s.
http://www.codechef.com/viewsolution/694301
def Z(N):
s = 0
for k in range(1, 13):
N /= 5
s += N
return s
def main():
T = int(raw_input())
for t in range(T):
N = int(raw_input())
print Z(N)
main()
the thing is there is almost no difference between the two, but the execution time is cut in half. i don’t understand why. even this is not related to your question, something is likely to be wrong in the execution time for Python.
This piqued my curiosity so I took a look at it.
First off, it’s nearly one year later and I assume things are different now than they were then (new versions of Python, different weights given to times, etc).
The OP’s Python 3 solution (given in the link) is accepted as is.
I played around with it anyway, specifically focusing on the I/O because the I/O in Python 3 has been completely redone and can really slow you down if you don’t know how to roll with it. My solution on the Judge was about 2x faster: 5.69s w/ Py3 vs 10.94s w/ Py2 & OP’s code.
OP’s code resubmitted:
http://www.codechef.com/viewsolution/1984772
My rework of OP’s code:
http://www.codechef.com/viewsolution/1984724
Regarding Python 3 I/O, I found this very helpful:
Something with the timing is definitely not working right. I tried the next question, and in Python 3 it exceeded the time limit, then resubmitting as Python 2 it also exceeded the time limit, and it passed after resubmitting almost exactly the same Python 2 code again.
See my submissions.
admin point of view requested ! thx
And for kicks, slightly faster:
http://www.codechef.com/viewsolution/1985673
Not sure how to eek out more performance.
Thanks all for sharing such information with us i don’t know the time limitation of python . I start to learn python after that I hope that term I understand.
Source: Python Training Institute in Delhi