from collections import deque
def solution(priorities, location):
answer = 0
q=[(i,j) for i,j in enumerate(priorities)]
# 파이썬에서 큐를 구현할 때 리스트 대신 deque를 쓰면 FIFO 속도가 더 빠름
q=deque(q)
while q:
max_num=max(priorities)
if q[0][1] >= max_num and q[0][0] == location:
answer+=1
break
elif q[0][1] >= max_num:
answer+=1
tmp=q.popleft()
priorities[tmp[0]]=0
else:
q.append(q.popleft())
return answer