Блог пользователя ovi_ivo

Автор ovi_ivo, 5 лет назад, По-английски

Hey there,

I solved 1214C - Bad Sequence of today's Codeforces Round 583 (Div. 1 + Div. 2, based on Olympiad of Metropolises) in Python3 and submitted it selecting PyPy3 as the compiler but I got TLE on test case 87. After the contest, I submitted the same code selecting Python3 as the compiler and got an AC.

Why so?

AC submission: 60028782; TLE submission: 60028578

Anyone care to clarify? Thanks.

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Looks like this is how list.pop(0) is implemented. Try to run this code in Python 3 and PyPy3:

b=[]
for i in range(100000):
    b.append(i)
    #if i%5==1: b.pop(0)
print( len(b) )

Without b.pop(0) line Python3 and PyPy3 executes this piece of code in around 125ms. While uncommenting pop(0) line turn this time into 155ms for Python3 and into 560ms for PyPy3. And if it would be 200k cycle you would get TLE. Experiment! :)