코딩

[이진탐색] 떡볶이 떡 만들기.py 본문

카테고리 없음

[이진탐색] 떡볶이 떡 만들기.py

ssooyn_n 2021. 7. 3. 02:29
start = 0
end = max(array)

result = 0
while(start <= end):
    total = 0
    mid = (start+end) //2
    for x in array:
        if x> mid:
            tatal += x - mid
    
    if total < m:
        end = mid - 1
    
    else:
        result = mid
        start = mid + 1

print(result)
Comments