Why difference in C++ and Python programs?

Правка en2, от IngaleAnkur10, 2019-03-13 16:49:22

I tried this problem: https://mirror.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://mirror.codeforces.com/contest/1136/submission/51256343.
Python Code 2 : https://mirror.codeforces.com/contest/1136/submission/51262124.
C++ code: https://mirror.codeforces.com/contest/1136/submission/51257855.

Thanks in advance.

Теги #c++, #python 3, #pypy3, #tle

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский IngaleAnkur10 2019-03-13 16:49:22 105 Tiny change: 'n/51257855' -> 'n/51257855. \n \nThanks in advance.' (published)
en1 Английский IngaleAnkur10 2019-03-13 16:45:31 572 Initial revision (saved to drafts)