파이썬/알고리즘
(파이썬)백준 알고리즘 1966번 프린터 큐
오지고지리고알파고포켓몬고
2017. 11. 3. 16:39
백준 알고리즘 저지 1966번 문제 (https://www.acmicpc.net/problem/1966)
for _ in range(int(input())): array_size, index = map(int, input().split(' ')) que = list(map(int, input().split(' '))) chk = [0 for _ in range(array_size)] chk[index] = 'T' count = 0 while True: if que[0] == max(que): count += 1 if chk[0] == 'T': print(count) break else: que.pop(0) chk.pop(0) else: que.append(que.pop(0)) chk.append(chk.pop(0))