본문 바로가기
python-algorithm

백준 1966 프린터 큐

by 무적김두칠 2022. 11. 8.

https://www.acmicpc.net/problem/1966

 

1966번: 프린터 큐

여러분도 알다시피 여러분의 프린터 기기는 여러분이 인쇄하고자 하는 문서를 인쇄 명령을 받은 ‘순서대로’, 즉 먼저 요청된 것을 먼저 인쇄한다. 여러 개의 문서가 쌓인다면 Queue 자료구조에

www.acmicpc.net

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from collections import deque
for i in range(int(input())):
    n, m = map(int, input().split())
    waiting= deque(list(map(int,input().split())))
    importance = deque(list([i for i in range(n)]))
    cnt = 0
    while waiting:
        if waiting[0== max(waiting):
            cnt+=1
            waiting.popleft()
            if importance.popleft() == m:
                print(cnt)
 
        else:
            waiting.append(waiting.popleft())
            importance.append(importance.popleft())
cs

 

반응형

'python-algorithm' 카테고리의 다른 글

백준 4949 균형잡힌 세상  (0) 2022.11.09
백준 18398 HOMWRK  (0) 2022.11.09
백준 10816 숫자 카드 2  (0) 2022.11.08
백준 11866 요세푸스 문제 0  (0) 2022.11.08
Hacker rank Super Reduced String  (0) 2022.11.08

댓글