-풀이
T = int(input())
for test_case in range(1, T + 1):
n, m = map(int, input().split())
queue = list(map(int, input().split()))
for i in range(m):
queue.append(queue.pop(0))
print('#{} {}'.format(test_case, queue[0]))
deque 모듈을 import해서도 구현이 가능하다.
'알고리즘' 카테고리의 다른 글
[백준] 2606. 바이러스 (Python) (0) | 2020.10.21 |
---|---|
[백준] 2667. 단지번호붙이기 (DFS/Python) (0) | 2020.10.21 |
[백준] 2589. 보물섬 (Python) (0) | 2020.10.21 |
[백준] 7576. 토마토 (Python) (0) | 2020.10.21 |
[백준] 1260. DFS와 BFS (Python) (0) | 2020.10.21 |