Skip to content

Commit a604f93

Browse files
committed
89차 1번, 2번 문제 순서 정정
1 parent 7406384 commit a604f93

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
n = int(input())
1+
n, m = map(int, input().split())
2+
arr = list(map(int, input().split()))
23

3-
arr = []
4-
5-
for i in range(n):
6-
arr.append(int(input()))
7-
8-
arr.sort()
4+
answer = 0
95

106
start = 0
117
end = 0
128

13-
max = float("-inf")
9+
cum_sum = arr[start]
1410

15-
while end < n:
16-
if arr[end] - arr[start] > 4:
11+
while end < len(arr):
12+
if cum_sum == m:
13+
answer += 1
14+
cum_sum -= arr[start]
1715
start += 1
18-
else:
19-
if end - start + 1 > max:
20-
max = end - start + 1
16+
elif cum_sum < m:
2117
end += 1
18+
if end < len(arr):
19+
cum_sum += arr[end]
20+
else:
21+
cum_sum -= arr[start]
22+
start += 1
2223

23-
24-
print(5-max)
24+
print(answer)

0 commit comments

Comments
 (0)