We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 952be59 commit 46abd1eCopy full SHA for 46abd1e
1 file changed
live11/test119/문제2/백한결.py
@@ -0,0 +1,26 @@
1
+import sys
2
+
3
+def main():
4
+ input = sys.stdin.readline
5
6
+ N, S = map(int, input().split())
7
+ sequence = list(map(int, input().split()))
8
9
+ start = 0
10
+ end = 0
11
+ current_sum = 0
12
+ result = float('inf')
13
14
+ while end != N:
15
+ if current_sum >= S:
16
+ result = min(result, end - start)
17
+ current_sum -= sequence[start]
18
+ start += 1
19
+ else:
20
+ current_sum += sequence[end]
21
+ end += 1
22
23
+ print(result if result != float('inf') else 0)
24
25
+if __name__ == '__main__':
26
+ main()
0 commit comments