We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a95851a commit d6f4f91Copy full SHA for d6f4f91
.gitignore
@@ -3,3 +3,9 @@
3
.idea/workspace.xml
4
.idea/misc.xml
5
.idea/codingtest.iml
6
+*.class
7
+*.xml
8
+BOJ_JAVA/.idea/misc.xml
9
+BOJ_JAVA/.DS_Store
10
+.DS_Store
11
+theory_Python/.DS_Store
Python_BOJ_2023/2512.py
@@ -0,0 +1,27 @@
1
+# 예산
2
+n = int(input())
+arra = list(map(int, input().split()))
+m = int(input())
+arra.sort()
+
+def binary_search(arr):
+ start = 0
+ end = max(arr)
+ while start <= end:
12
+ mid = (start + end) // 2
13
+ print(start, end, mid)
14
+ cnt = 0
15
+ for i in range(n):
16
+ if arr[i] >= mid:
17
+ cnt += mid
18
+ else:
19
+ cnt += arr[i]
20
+ if cnt <= m:
21
+ start = mid + 1
22
23
+ end = mid - 1
24
+ return end
25
26
+answer = binary_search(arra)
27
+print(answer)
0 commit comments