[2022.02.09]
T = int(input())
for tc in range(T):
K,N,M = map(int, input().split())
stations = list(map(int, input().split()))
cnt = 0
bus = 0
# 도착지를 stations에 추가
stations.append(N)
# 도착 불가능 버스
is_able = True
for s in range(1,len(stations)):
if stations[s]-stations[s-1] > K:
is_able = False
break
if not is_able :
print(f'#{tc + 1} {0}')
continue
# 도착 가능한 버스
while True:
# 종료조건 : bus가 N에 도착했을 때 종료
if bus >= N:
print(f'#{tc + 1} {cnt-1}') # 도착한 후 cnt +1 된 건 제거
break
bus += K
if bus in stations:
cnt += 1
else :
while not(bus in stations):
bus -= 1
cnt += 1
'코딩테스트 > SWExpertAcademy' 카테고리의 다른 글
[Python] SWEA 13569 - gravity (0) | 2022.04.13 |
---|---|
[Python] SWEA 4835 - 구간합 (0) | 2022.04.13 |
[Python] SWEA 4834 - 숫자카드 (0) | 2022.04.13 |
[Python] SWEA 4828 - min max (0) | 2022.04.13 |
[Python] SWEA 1206 - View (0) | 2022.04.13 |
댓글