Why difference in C++ and Python programs?

Revision en2, by IngaleAnkur10, 2019-03-13 16:49:22

I tried this problem: https://codeforces.com/contest/1136/problem/D.
And came up with a solution similar to the solution in the editorial.
But I first submitted my Python code in both Python3 and PyPy3 and had TLE.
But when I submitted an ALMOST equivalent code in C++, it got accepted.
I wonder what's wrong in my python code or is it the compiler's/interpreter's doing?

Python Code 1 : https://codeforces.com/contest/1136/submission/51256343.
Python Code 2 : https://codeforces.com/contest/1136/submission/51262124.
C++ code: https://codeforces.com/contest/1136/submission/51257855.

Thanks in advance.

Tags #c++, #python 3, #pypy3, #tle

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English IngaleAnkur10 2019-03-13 16:49:22 105 Tiny change: 'n/51257855' -> 'n/51257855. \n \nThanks in advance.' (published)
en1 English IngaleAnkur10 2019-03-13 16:45:31 572 Initial revision (saved to drafts)