We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 276bb25 commit 099026dCopy full SHA for 099026d
1 file changed
live11/test119/문제2/박희경.py
@@ -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