백준 1021 파이썬 회전하는 큐
회전하는 큐 왼쪽으로 돌릴 때는 index가 0인 원소를 뒤에 넣고 앞을 삭제, 오른쪽으로 돌릴 때는 index가 -1인 원소를 앞에 넣고 뒤를 삭제하면 된다 import sys N, M = map(int, sys.stdin.readline().split()) K = list(map(int, sys.stdin.readline().split())) A = [i for i in range(1, N + 1)] cnt = 0 for i in range(M): A_len = len(A) A_index = A.index(K[i]) if A_index < A_len - A_index: while True: if A[0] == K[i] : del A[0] break else : A.append(A[0]) del A[0..