Skip to content

Commit 099026d

Browse files
committed
119차 2번 다시 문제풀이
1 parent 276bb25 commit 099026d

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import sys
2+
3+
input = sys.stdin.readline
4+
5+
n, s = map(int, input().split())
6+
arr = list(map(int, input().split()))
7+
8+
i, j = 0, 0
9+
prefix_sum = arr[0]
10+
res = float('inf')
11+
12+
while True:
13+
if j >= n:
14+
break
15+
if prefix_sum >= s:
16+
res = min(res, j-i+1)
17+
prefix_sum -= arr[i]
18+
i += 1
19+
else:
20+
j += 1
21+
if j < n:
22+
prefix_sum += arr[j]
23+
24+
if res != float('inf'):
25+
print(res)
26+
else:
27+
print(0)

0 commit comments

Comments
 (0)