We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 80f599f commit 3e11a88Copy full SHA for 3e11a88
1 file changed
live8/test86/문제2/박희경.py
@@ -0,0 +1,39 @@
1
+import sys
2
+
3
4
+def binary_search(arr, target):
5
+ start, end = 0, max(arr)
6
+ while start <= end:
7
+ mid = (start + end) // 2
8
+ total = 0
9
+ for i in arr:
10
+ if i > mid:
11
+ total += mid
12
+ else:
13
+ total += i
14
+ if total > target:
15
+ end = mid - 1
16
17
+ start = mid + 1
18
+ return end
19
20
21
+input = sys.stdin.readline
22
23
+n = int(input())
24
+budget = list(map(int, input().split()))
25
+m = int(input())
26
27
+budget.sort() # 110 120 140 150
28
+print(binary_search(budget, m))
29
30
31
+"""
32
+4
33
+120 110 140 150
34
+485
35
36
+5
37
+70 80 30 40 100
38
+450
39
0 commit comments