프로그래밍 언어/python

입 출력 속도 개선

EastHoon 2020. 10. 9. 17:17

한 줄 입력

from sys import stdin

n = int(stdin.readline())

 

리스트 입력

_list = list(map(int, stdin.readline().split())) # 한줄 읽어 들이고, 공백을 기준으로 분할 한뒤, int로 맵핑한다.

 

2차원 배열 입력

arr = []
for i in range(col_len):
	arr.append(list(map(int, stdint.readline().split()))) # append를 쓰는 것이 arr[i]로 접근 하는 것 보다 조금 빠르다.

 

 

[Reference]

https://breakcoding.tistory.com/109

반응형