diff --git a/Algorithm/BOJ/2512.py b/Algorithm/BOJ/2512.py new file mode 100644 index 0000000..b1b76cd --- /dev/null +++ b/Algorithm/BOJ/2512.py @@ -0,0 +1,24 @@ +n = int(input()) +array = list(map(int, input().split())) +m = int(input()) + +start = 0 +end = max(array) + +result = 0 + +while(start <= end): + total = 0 + mid = (start + end) // 2 + for x in array: + if x >= mid: + total += mid + else: + total += x + + if total <= m: + start = mid + 1 + else: + end = mid - 1 + +print(end) \ No newline at end of file