[search] 백준 #2792 보석상자

zio·2022년 2월 28일
0

Algorithm

목록 보기
11/11

문제

https://www.acmicpc.net/problem/2792

풀이

# 보석상자
import math, sys
input = sys.stdin.readline
n, m = map(int, input().split())
color = [int(input()) for _ in range(m)]

start = 1
end = max(color)
result = 0
while start <= end:
    mid = (start+end)//2
    total = 0
    for c in color:
        total += math.ceil(c/mid)

    if total > n:
        start = mid + 1
    else:
        result = mid
        end = mid - 1

print(result)

접근

이분탐색을 이용한다.

profile
🐣

0개의 댓글