hikenny 2023. 12. 13. 09:49
from collections import deque

for t in range(int(input())):
    n, m = map(int, input().split())
    deq = deque(list(map(int, input().split())))

    for i in range(m):
        tmp = deq.popleft()
        deq.append(tmp)

    print(f"#{t+1} {deq[0]}")

 

쉬운 큐 구현 문제..

파이썬은 deque 제공 하므로 이용해서 쉽게 풀어주엇다