프로그래밍/삼성 SWEA

[SWEA][Python3] 5357. 터널 속의 기차

snoopybox 2019. 5. 2. 01:33

나의 풀이 :

T = int(input())
for tc in range(1, T + 1):
N, H = map(int, input().split())
A = list(map(int, input().split()))
O = list(map(int, input().split()))
ans = 0 if O[0] else 1
off = 0
for i in range(1, N):
if O[i]:
off = 0
else:
off += A[i]
if off >= H:
ans += 1
off = 0
O[i] = 1
if N > 1 and not O[-1]:
ans += 1
print('#%s %s' % (tc, ans))


한마디 :

처음과 끝을 조심해야 한다.