We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7e88e16 commit 83289dfCopy full SHA for 83289df
1 file changed
live9/test97/문제3/백유진.py
@@ -0,0 +1,24 @@
1
+def solution(distance, rocks, n):
2
+ rocks.sort()
3
+ rocks.append(distance)
4
+ left, right = 1, distance
5
+ answer = 0
6
+
7
+ while left <= right:
8
+ mid = (left + right) // 2
9
+ prev = 0
10
+ removed = 0
11
12
+ for rock in rocks:
13
+ if rock - prev < mid:
14
+ removed += 1
15
+ else:
16
+ prev = rock
17
18
+ if removed > n:
19
+ right = mid - 1
20
21
+ answer = mid
22
+ left = mid + 1
23
24
+ return answer
0 commit comments