-
1966 프린터 큐코테 대비 python/백준 2023. 4. 10. 22:59
https://www.acmicpc.net/problem/1966
from collections import deque T=int(input()) for _ in range(T): n,m = map(int,input().split()) w = list(map(int,input().split())) que=[0]*n index=[0]*n cnt=0 #순서와 가중치 저장 for i in range(len(w)): que[i] = w[i] index[i] = i #popleft쓰려고 덱으로 변환 q = deque(que) idx = deque(index) # 만약 왼쪽값이 크다면 그냥 출력 while q: if q[0] >= max(q): q.popleft() a=idx.popleft() cnt+=1 if a==m: print(cnt) # 만약 왼쪽게 작다면 뽑고 뒤로 어팬드 elif q[0] < max(q): b=q.popleft() q.append(b) c=idx.popleft() idx.append(c)
'코테 대비 python > 백준' 카테고리의 다른 글
1181 단어 정렬 (0) 2023.04.11 14503 로봇 청소기 (0) 2023.04.11 13335 트럭 (0) 2023.04.10 14888 연산자 끼워넣기 (0) 2023.04.04 13458 시험감독 (0) 2023.03.29