We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7406384 commit a604f93Copy full SHA for a604f93
1 file changed
live8/test89/문제2/백유진.py
@@ -1,24 +1,24 @@
1
-n = int(input())
+n, m = map(int, input().split())
2
+arr = list(map(int, input().split()))
3
-arr = []
4
-
5
-for i in range(n):
6
- arr.append(int(input()))
7
8
-arr.sort()
+answer = 0
9
10
start = 0
11
end = 0
12
13
-max = float("-inf")
+cum_sum = arr[start]
14
15
-while end < n:
16
- if arr[end] - arr[start] > 4:
+while end < len(arr):
+ if cum_sum == m:
+ answer += 1
+ cum_sum -= arr[start]
17
start += 1
18
- else:
19
- if end - start + 1 > max:
20
- max = end - start + 1
+ elif cum_sum < m:
21
end += 1
+ if end < len(arr):
+ cum_sum += arr[end]
+ else:
22
+ start += 1
23
24
-print(5-max)
+print(answer)
0 commit comments