내가 푼 코드, 파이썬이니까 append, pop이용함
T = int(input())
for tc in range(1,T+1):
N, M = map(int,input().split())
arr = list(map(int,input().split()))
for _ in range(M):
arr.append(arr.pop(0))
print(f'#{tc} {arr[0]}')
다른 분이 푼 코드 (길이 150자)
T = int(input())
for tc in range(1, T+1):
N, M = map(int, input().split())
arr = list(map(int, input().split()))
print(f'#{tc} {arr[M % N]}')
'알고리즘 문제풀이' 카테고리의 다른 글
Swea D3_11885.피자굽기 Python Queue (0) | 2024.02.16 |
---|---|
Swea D2_1225.암호생성기 Python Queue (0) | 2024.02.15 |
Swea D2_1954 달팽이 Python (0) | 2024.02.15 |
Swea D3_11883. 배열 최소합 Python 재귀,백트래킹 (0) | 2024.02.14 |
Swea D3_11881. 4880. 토너먼트 문제풀이 Python 분할정복 (0) | 2024.02.14 |