We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0ca6ba3 commit 80f599fCopy full SHA for 80f599f
1 file changed
live8/test86/문제1/박희경.py
@@ -0,0 +1,34 @@
1
+import sys
2
+
3
4
+def binary_search(arr, target):
5
+ start, end = 0, max(arr)
6
7
+ while start <= end:
8
+ mid = (start + end) // 2
9
+ high = 0
10
+ for i in arr:
11
+ if i > mid:
12
+ high += i - mid
13
+ if high < target: # 높이를 낮출 필요가 있음
14
+ end = mid - 1
15
+ else: # target이랑 일치해도 최대 높이를 구해야하니까
16
+ start = mid + 1
17
+ return end
18
19
20
+input = sys.stdin.readline
21
22
+n, m = map(int, input().split())
23
+h = list(map(int, input().split()))
24
25
+h.sort() # 10, 15, 17, 20
26
+print(binary_search(h, m))
27
28
+"""
29
+4 7
30
+20 15 10 17
31
32
+5 20
33
+4 42 40 26 46
34
0 commit comments