From 0cf4a2b3a0c7c581c2dadbc37e5b9e5b5a008c7f Mon Sep 17 00:00:00 2001 From: yoonseo Date: Fri, 4 Mar 2022 01:49:46 +0900 Subject: [PATCH] =?UTF-8?q?=EC=98=88=EC=82=B0=20(#6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Algorithm/BOJ/2512.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Algorithm/BOJ/2512.py 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