여름의 서재

[백준] 1966_프린터 큐 본문

알고리즘/BOJ

[백준] 1966_프린터 큐

엉아_ 2021. 8. 11. 17:23
728x90
from collections import deque

T = int(input())

for _ in range(T):
    N, K = map(int,input().split())
    lst = deque(map(int,input().split()))
    target = deque(0 for _ in range(N))
    target[K]=1
    temp = 0
    while sum(target):
        if lst[0] == max(lst):
            lst.popleft()
            target.popleft()
            temp+=1
        else : 
            lst.append(lst.popleft())
            target.append(target.popleft())
    print(temp)

'알고리즘 > BOJ' 카테고리의 다른 글

[백준] 1541_잃어버린 괄호  (0) 2021.08.12
[백준] 1018_체스판 다시 칠하기  (0) 2021.08.12
[백준] 17413_단어 뒤집기 2  (0) 2021.08.11
[백준] 1120_문자열  (0) 2021.08.11
[백준] 1021_회전하는 큐  (0) 2021.08.11
Comments