Skip to content

Commit a3ec3d5

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

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

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

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

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

610
start = 0
711
end = 0
812

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

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

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

0 commit comments

Comments
 (0)