# 프린터

프린터 - 프로그래머스

from collections import deque

def solution(priorities, location):
    q = deque()
    for idx, i in enumerate(priorities):
        q.append((i, idx))
    cnt = 0
    while True:
        if len(q) == 1:
            cnt += 1
            break
        J = q.popleft()
        if J[0] < max(q)[0]:
            q.append(J)
        else:
            cnt += 1
            if J[1] == location:
                break
    return cnt