1. dot operator를 사용하면 성능에 저하가 오므로, 변수로 정의하여 사용하면 30%가량 성능이 향상된다.
arr3 = []
arr3_adder = arr3.append
arr3_adder(12345)
2. 입력함수 input()보다 import sys + sys.stdin.readlin()이 빠르다.
arr = list(map(int, input().split()))
대신
import sys
arr = list(map(int, (sys.stdin.readline()).split() ))
를 쓰도록 하자. 단, input()과는 달리 realine() 입력의 \n까지도 읽어버린다. 주의하자!
또는 list(map(int,sys.stdin))
를 쓰도록하자. 그러나 이 방법은 세로로 input값이 주어질 때 쓰도록하자.
'개발 > 알고리즘' 카테고리의 다른 글
1912 연속합 (0) | 2019.03.22 |
---|---|
합병정렬 (0) | 2019.03.19 |
Codeforces Global Round 1 (A. Parity) (0) | 2019.02.08 |
4949 The Balance of the World (0) | 2019.01.24 |
2312 수 복원하기 (0) | 2019.01.24 |