
[Python] 백준 #1021- 회전하는 큐
·
코딩테스트/백준[Python]
문제 1021번: 회전하는 큐 첫째 줄에 큐의 크기 N과 뽑아내려고 하는 수의 개수 M이 주어진다. N은 50보다 작거나 같은 자연수이고, M은 N보다 작거나 같은 자연수이다. 둘째 줄에는 지민이가 뽑아내려고 하는 수의 위치가 www.acmicpc.net 코드 My answer import sys from collections import deque input=sys.stdin.readline n,m=map(int,input().split()) a=deque([i+1 for i in range(n)]) b=list(map(int,input().split())) cnt=0 while(len(b)!=0): if(a[0]==b[0]): a.popleft() b.pop(0) else: ind=a.index(b[..