sybby   2년 전

radix sort로 구현했는데요.pypy로 돌리면 '틀렸습니다'가 나오고, python3으로 돌리면 시간초과가 납니다. 아무리 돌려봐도 에러는 없어보이는데 뭐가 문제인지 모르겠네요

djm03178   2년 전

반례입니다.

kyako95   2년 전

코드가 틀려서 오답 처리 되는 것 외에도 python3에서 시간 초과가 나는 이유는 그냥 python과 deque가 원래 느려서 그렇습니다.

import time
current = time.time()

a=[]
for i in range(5_000_000):
    a.append(i)

print(time.time()-current) # 0.4초
import time
from collections import deque
current = time.time()

a=deque()
for i in range(5_000_000):
    a.append(i)

print(time.time()-current) # 0.35초

댓글을 작성하려면 로그인해야 합니다.