본문 바로가기

CodingTest/Baekjun Online Judge

[ 백준 / BOJ ] 1966 프린터 큐

/  제출 1  /

 

from collections import deque

T = int(input())
for _ in range(T):
  n, target =  map(int, input().split())
  docs = enumerate(list(map(int, input().split())))

  docs = deque(docs)
  print(docs)
  count = 0
  while docs:
    now = docs.popleft()
    count += 1
    if docs:
      for doc in docs:
        if now[1] < doc[1]:
          count -= 1
          docs.append(now)
          break
    if now[0] == target and now not in docs:
      break
    
  
  print(count)

 

풀이 소요시간: 22분

 

 

프린터에 1장 들어왔을 때를 고려하면서 시간이 조금 딜레이됐습니다.

비교적 간단하게 풀어져서 다행이었습니다.

enumerate로 각 문서에 이름을 달아주는 개념으로 해서 찾고자 하는 문서를 찾기 쉽게 만들었습니다.