Skip to content

Commit be3b09b

Browse files
committed
89차 1번 문제풀이
1 parent 949df2d commit be3b09b

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

live8/test89/문제1/백유진.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
n, m = map(int, input().split())
2+
arr = list(map(int, input().split()))
3+
4+
answer = 0
5+
6+
start = 0
7+
end = 0
8+
9+
cum_sum = arr[start]
10+
11+
while end < len(arr):
12+
if cum_sum == m:
13+
answer += 1
14+
cum_sum -= arr[start]
15+
start += 1
16+
elif cum_sum < m:
17+
end += 1
18+
if end < len(arr):
19+
cum_sum += arr[end]
20+
else:
21+
cum_sum -= arr[start]
22+
start += 1
23+
24+
print(answer)

0 commit comments

Comments
 (0)