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