Problem:
 Score : 500 points    Problem Statement We have N logs of lengths A_1,A_2,\cdots A_N .  We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t  (0<t<L) , it becomes two logs of lengths t and L-t .  Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.      Constraints  1 \leq N \leq 2 \times 10^5  0 \leq K \leq 10^9  1 \leq A_i \leq 10^9  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  K  A_1  A_2  \cdots  A_N       Output Print an integer representing the answer.        Sample Input 1 2 3
7 9      Sample Output 1 4   First, we will cut the log of length 7 at a point whose distance from an end of the log is 3.5 , resulting in two logs of length 3.5 each.  Next, we will cut the log of length 9 at a point whose distance from an end of the log is 3 , resulting in two logs of length 3 and 6 .  Lastly, we will cut the log of length 6 at a point whose distance from an end of the log is 3.3 , resulting in two logs of length 3.3 and 2.7 .   In this case, the longest length of a log will be 3.5 , which is the shortest possible result. After rounding up to an integer, the output should be 4 .       Sample Input 2 3 0
3 4 5      Sample Output 2 5       Sample Input 3 10 10
158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202      Sample Output 3 292638192

Solution (Python):
from math import ceil
n,k=map(int,input().split())
a=list(map(int,input().split()))
l,r=0,10**9
while r-l>1:
    m=(r+l)//2
    count=0
    for i in a:
        count+=ceil(i/m)-1
    if count<=k:
        r=m
    else:
        l=m
print(r)

Solution (Python):
N, K = map(int, input().split())
A = list(map(int, input().split()))

def isOK(x):
    cnt = 0
    for a in A:
        cnt += (a + x - 1) // x - 1
    return cnt <= K

left, right = 0, 10 ** 10
while right - left > 1:
    mid = (left + right) // 2
    if isOK(mid):
        right = mid
    else:
        left = mid
print(right)

Solution (Python):
def is_ok(X):
    cnt = 0
    for a in A:
        cnt += -(-a//X)-1
    if cnt <= k:
        return True
    else:
        return False


def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

n, k = map(int,input().split())
A = list(map(int,input().split()))

print(meguru_bisect(0,max(A)+1))

Solution (Python):
def is_ok(X):
    cnt = 0
    for a in A:
        cnt += (a-1)//X
    if cnt <= k:
        return True
    else:
        return False


def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

n, k = map(int,input().split())
A = list(map(int,input().split()))

print(meguru_bisect(0,max(A)+1))

Solution (Python):
n,k = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
x,y=0,10**9
while y>x+1:
    m = (x+y)//2
    c=0
    for i in l:
        c+=(i-1)//m
    if c<=k:
        y=m
    else:
        x=m
print(y)

Solution (Python):
import sys
import math
import itertools
import collections
from collections import deque
from collections import defaultdict

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD2 = 998244353
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N, K = NMI()
    A = NLI()
    
    ng = 0       
    ok = 10**9+10  

    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2

        cut = 0
        for a in A:
            if a % mid == 0:
                cut += math.floor(a/mid)-1
            else:
                cut += math.floor(a/mid)


        if cut <= K:
            ok = mid
        else:
            ng = mid

    print(ok)
    

if __name__ == '__main__':
    main()

Solution (Python):

import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)





def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N, K = zz()
A = zz()
max_a = max(A)
rest = K





def trial(x):
    
    num_cut = 0
    for a in A:
        num_cut += (-(-a//x)-1)
        
        if (num_cut > K):
            return False
    return True



l = 0
r = max_a
while (r - l > 1):
    ans = (l + r) // 2
    if (trial(ans)):
        
        r = ans
    else:
        l = ans
print(r)

Solution (Python):
N,K = map(int,input().split())
A = list(map(int,input().split()))

def f(n):
    now = 0
    for i in range(N):
        now += (A[i]-1)//x
    if now <= K:
        return True
    else:
        return False

l = 0; r = 10**10
while r-l > 1:
    x = (l+r)//2
    if f(x):
        r = x
    else:
        l = x
print(r)

Solution (Python):
N,K = map(int,input().split())
A = list(map(int,input().split()))

def f(x):
    if x!= 0:
        now = 0
        for i in range(N):
            now += (A[i]-1)//x
        return now <= K
    else:
        return False
l = 0; r = 10**10
while r-l > 1:
    x = (l+r)//2
    if f(x):
        r = x
    else:
        l = x
print(r)

Solution (Python):
def check(x, A, K):
    import math
    sumA = 0
    for a in A:
        if a > x:
            sumA += math.ceil(a / x) - 1
    if sumA <= K:
        return True
    else:
        return False


def resolve():
    _, K = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]

    ok = max(A)  
    ng = -1  
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if mid > 0 and check(mid, A, K):
            ok = mid
        else:
            ng = mid
    print(ok)


resolve()

Solution (Python):
import base64

exec(base64.b85decode(b'X>D+Ca&

Solution (Python):
N, K = map(int, input().split())
*A, = map(int, input().split())

def f(t):
    return sum(i//t if i!=t else 0 for i in A)<=K if t else all(i<=t for i in A)

l, r = -1, 10**10
while r-l>1:
    m = (r+l)//2
    if f(m):
        r = m
    else:
        l = m

print(r)

Solution (Python):
N, K = map(int, input().split())
*A, = map(int, input().split())

def f(t):
    if t!=0:
        c = 0
        for i in A:
            c += i//t if i!=t else 0
        return c<=K
    else:
        return all(i<=t for i in A)

left, right = -1, 10**10
while right-left>1:
    m = (right+left)//2
    if f(m):
        right = m
    else:
        left = m

print(right)

Solution (Python):
import base64

exec(base64.b64decode(b'aW1wb3J0IHN1YnByb2Nlc3MKaW1wb3J0IHN5cwoKY29kZSA9IHIiIiIjaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8Yml0c2V0PgojaW5jbHV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bWlkOwogICAgfQogIH0KCiAgY291dCA8PCBoaWdoIDw8IGVuZGw7CgogIHJldHVybiAwOwp9CiIiIgoKd2l0aCBvcGVuKCdzb2wuY3BwJywgJ3cnKSBhcyBmOgogICAgZi53cml0ZShjb2RlKQoKc3VicHJvY2Vzcy5Qb3BlbihbJ2crKycsICctc3RkPWMrKzE3JywgJy1PMicsICdzb2wuY3BwJ10pLmNvbW11bmljYXRlKCkKc3VicHJvY2Vzcy5Qb3BlbihbJy4vYS5vdXQnXSwgc3RkaW49c3lzLnN0ZGluLCBzdGRvdXQ9c3lzLnN0ZG91dCkuY29tbXVuaWNhdGUoKQ=='))

Solution (Python):
def solve():
    N, K = map(int,input().split())
    A = list(map(int,input().split()))

    left = 0
    right = 10 ** 9
    while right - left > 1:
        mid = (right+left) // 2
        cnt = 0
        for a in A:
            cnt += (a-1) // mid
        
        if cnt <= K:
            right = mid
        else:
            left = mid

    print(right)
    
if __name__ == '__main__':
    solve()

Solution (Python):
from math import ceil
def solve():
    N, K = map(int,input().split())
    A = list(map(int,input().split()))

    left = 0
    right = 10 ** 9
    while (right - left) > 1:
        x = (left+right) // 2
        cnt = 0
        for a in A:
            cnt += (a-1) // x
        
        if cnt <= K:
            right = x
        else:
            left = x
    
    print(right)
    
if __name__ == '__main__':
    solve()

Solution (Python):
from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,k = readInts()
a = readInts()

a.sort(reverse=True)

if n==1:
	print(math.ceil(a[0]/(k+1)))
	exit()

def get(left, right):
	l = (right-left)//2+left
	ans = 0
	for i in a:
		ans+=math.ceil(i/l)-1
	
	return ans,l

def nibu(left,right):
	ans,l = get(left, right)

	if left<right:
		if ans<=k:
			return nibu(left,l)
		else:
			return nibu(l+1, right)
	else:
		return right


print(nibu(1,a[0]))

Solution (Python):
from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,k = readInts()
a = readInts()

a.sort(reverse=True)

if n==1:
	print(math.ceil(a[0]/(k+1)))
	exit()

def get(left, right):
	l = (right-left)//2+left
	ans = 0
	for i in a:
		ans+=math.ceil(i/l)-1
	
	return ans,l

def nibu(left,right):
	ans,l = get(left, right)

	if left<right:
		if ans<=k:
			return nibu(left,l)
		else:
			return nibu(l+1, right)
	else:
		return right


print(nibu(1,a[0]))

Solution (Python):


def isOK(i, key):
    '''
    問題に応じて返り値を設定
    '''
    cnt = 0
    for v in a:
        cnt += (v + i - 1) // i - 1

    return cnt <= key


def binary_search(key):
    '''
    条件を満たす最小/最大のindexを求める
    O(logN)
    '''
    ok = 10 ** 9  
    ng = 0        
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2

        if isOK(mid, key):  
            ok = mid
        else:
            ng = mid
    
    return ok


n, k = map(int, input().split())
a = list(map(int, input().split()))
 
print(binary_search(k))

Solution (Python):

import sys
import math
from decimal import Decimal, ROUND_HALF_UP


def main():
    N,K = list(map(int, sys.stdin.readline().split()))
    A_list = list(map(int, sys.stdin.readline().split()))
 
 
    def check(length :int) -> bool:
        cnt = 0
 
        for a in A_list:
            if a >= length:
                divide = math.ceil(a / length)
                cnt += (divide - 1)
        
        return (True if cnt <= K else False)
 
 
    L = 0.1          
    R = max(A_list)  
 
    while (R - L) > 0.01:
        M = L + (R - L) / 2
 
        if check(M):
            R = M
        else:
            L = M
    
    
    ans = Decimal(str(M)).quantize(Decimal('1E-1'), rounding=ROUND_HALF_UP)
    ans = math.ceil(ans)

    print(ans)



if __name__ == "__main__":
    main()

Solution (Python):

import sys
import math


def main():
    N,K = list(map(int, sys.stdin.readline().split()))
    A_list = list(map(int, sys.stdin.readline().split()))


    def check(length :int) -> bool:
        cnt = 0

        for a in A_list:
            if a >= length:
                divide = math.ceil(a / length)
                cnt += (divide - 1)
        
        return (True if cnt <= K else False)


    L = 0            
    R = max(A_list)  

    while (R - L) > 1:
        M = L + (R - L) // 2

        if check(M):
            R = M
        else:
            L = M


    print(R)


if __name__ == "__main__":
    main()

Solution (Python):

import sys
import math


def main():
    N,K = list(map(int, sys.stdin.readline().split()))
    A_list = list(map(int, sys.stdin.readline().split()))


    def check(length :int) -> bool:
        cnt = 0

        for a in A_list:
            if a >= length:
                quotient = a / length
                
                divide = math.ceil(quotient)  
                cnt += (divide - 1)
        
        return (True if cnt <= K else False)


    L = 0            
    R = max(A_list)  

    while (R - L) > 1:
        M = L + (R - L) // 2

        if check(M):
            R = M
        else:
            L = M


    print(R)


if __name__ == "__main__":
    main()

Solution (Python):

import sys
from decimal import Decimal, ROUND_HALF_UP


def main():
    N,K = list(map(int, sys.stdin.readline().split()))
    A_list = list(map(int, sys.stdin.readline().split()))


    def check(length :int) -> bool:
        cnt = 0

        for a in A_list:
            if a >= length:
                quotient = a / length
                divide = -(-quotient // 1)  
                cnt += (divide - 1)
        
        return (True if cnt <= K else False)


    L = 0            
    R = max(A_list)  

    while (R - L) > 1:
        M = L + (R - L) // 2

        if check(M):
            R = M
        else:
            L = M


    print(R)


if __name__ == "__main__":
    main()

Solution (Python):
n, k = [int(i) for i in input().split()]
woods = [int(i) for i in input().split()]


def k_cut_less_than(k, l, woods):
    kaisuu = 0
    for wood in woods:
        kaisuu += (wood-1) // l
    if kaisuu <= k:
        return False
    return True





import math


def binary_research(start, end,  function):
    if start == end:
        return start
    middle = math.ceil((start + end) / 2)
    if function(k, middle, woods):
        start = middle
    else:
        end = middle - 1
    return binary_research(start, end, function)

start=0
end=10**9
print(binary_research(start,end,k_cut_less_than)+1)

Solution (Python):

import sys
from decimal import Decimal, ROUND_HALF_UP


def main():
    N,K = list(map(int, sys.stdin.readline().split()))
    A_list = list(map(int, sys.stdin.readline().split()))


    def check(length :int) -> bool:
        cnt = 0

        for a in A_list:
            if a >= length:
                quotient = a / length
                divide = -(-quotient // 1)  
                cnt += (divide - 1)
        
        return (True if cnt <= K else False)


    L = 0.1            
    R = max(A_list)  

    while (R - L) > 0.01:
        M = L + (R - L) / 2

        if check(M):
            R = M
        else:
            L = M
    
    
    ans = float( Decimal(str(M)).quantize(Decimal('1E-1'), rounding=ROUND_HALF_UP) )
    ans = -(-ans // 1)  
    print( int(ans) )


if __name__ == "__main__":
    main()

Solution (Python):
n, k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()

ok = a[-1]
ng = 0
while abs(ok - ng)>1:
    X = (ok + ng)//2
    
    cnt = 0
    for i in range(n):
        temp = a[-(i + 1)]
        if temp <= X:break
        temp_cnt = (temp + X - 1)//X - 1
        cnt += temp_cnt
    
    if cnt <= k:ok = X
    else:ng = X
    
print(ok)

Solution (Python):
import math

N,K=map(int,input().split())
A=list(map(int, input().split()))
l=0
r=max(A)
while not l+1==r:
    x=(r+l)//2
    k=0
    for a in A:
        k+=math.ceil(a/x)-1
    if k<=K:
        r=x
    else:
        l=x
print(r)

Solution (Python):
from math import ceil

def check(x):
    cnt = 0
    for a in A:
        cnt += ceil(a/x)-1
    return cnt <= K

N, K = map(int, input().split())
A = list(map(int, input().split()))

left = 0
right = max(A)
while left < right-1:
    mid = (left+right)//2
    if check(mid):
        right = mid
    else:
        left = mid
print(right)

Solution (Python):
from math import ceil


def check(x):
    
    cnt = 0
    for a in A:
        
        cnt += ceil(a/x)-1
    return cnt <= K


N, K = map(int, input().split())
A = list(map(int, input().split()))

left = 0
right = max(A)
while left < right-1:
    mid = (left+right)//2
    if check(mid):
        right = mid
    else:
        left = mid
print(right)

Solution (Python):


N,K=map(int,input().split())

A=list(map(float, input().split()))

low=0
high=10**9+1

while high-low!=1:
    mid=(high+low)//2
    cut_temp=0
    ans=-1
    
    for a in A:
        cut_temp+=-(-a//mid)-1
    if cut_temp>K:
        low=mid
    else:
        high=mid
    
print(high)

Solution (Python):
"""ABC174E diff: 1158
"""

N,K=map(int,input().split())
A=list(map(int, input().split()))

if K == 0:
    print(max(A))
    exit()

def f(x):
    """
    K回以内のカットで全ての丸太の長さをX以下にできるか？
    X: int
    Return: bool
    """
    cnt = 0
    for a in A:
        if a % x == 0:
            cnt += a//x - 1
        else:
            cnt += a//x
    
    if cnt <= K:
        return True
    else:
        return False

left = 0
right = max(A) + 10

while right - left > 1:
    mid = (left+right) // 2
    if f(mid):
        right = mid
    else:
        left = mid
print(right)

Solution (Python):
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))

left = 0
right = max(A)

while right - left > 1:
    mid = (left + right) // 2
    jk = 0
    for i in range(N):
        jk += A[i] // mid - 1
        if A[i] % mid != 0: jk += 1
    if jk <= K:
        right = mid
    else:
        left = mid

print(right)

Solution (Python):
n, k = map(int, input().split())
a = [i-1 for i in map(int, input().split())]
left, right = 1, 10**9
while left < right:
    middle = (left + right)//2
    count = sum(i//middle for i in a)
    if count <= k:
        right = middle
    else:
        left = middle + 1
print(left)

Solution (Python):
n, k = map(int, input().split())
a = [i-1 for i in map(int, input().split())]

left, right = 1, 10**9
while left < right:
    middle = (left + right)//2

    count = 0
    for i in a:
        count += i//middle
    
    if count <= k:
        right = middle
    else:
        left = middle + 1

print(left)

Solution (Python):
n, k = map(int, input().split())
a = [i-1 for i in map(int, input().split())]

left, right = 0, 10**9
while left < right:
    middle = (left+right)//2
    if middle==0:
        left=1
        break
    count = 0
    for i in a:
        count += i//middle
    
    if count <= k:
        right = middle
    else:
        left = middle + 1

print(left)

Solution (Python):
n, k = map(int, input().split())
a = [i-1 for i in map(int, input().split())]

left, right = 0, 10**9
while left < right:
    middle = (left+right)//2
    if middle==0:
        left=1
        break
    count = 0
    for i in a:
        count += i//middle
    
    if count <= k:
        right = middle
    else:
        left = middle + 1

print(left)

Solution (Python):
import math
n,k=map(int, input().split())
a=list(map(int, input().split()))
right=max(a)
left=0
def cutable(a,x):
    count=0
    for i in a:
        count+=math.ceil(i/x)-1
    return count<=k
while right>left+1:
    mid=(right+left)//2
    if cutable(a,mid):
        right=mid
    else:
        left=mid
print(right)

Solution (Python):

import sys
sys.setrecursionlimit(1000000)

N,K = map(int,input().split())
A = list(map(int,input().split()))

def rec(l,r):
    global N,K,A
    if l==r:
        return l
    tmp = (l+r)//2
    ans = 0
    for i in range(N):
        ans += (A[i]-0.001)//tmp
    if ans<=K:
        return rec(l,tmp)
    else:
        return rec(tmp+1,r)
    
print(rec(1,max(A)))

Solution (Python):
N,K=map(int,input().split())
*A,=map(int,input().split())

def C(x):
  return sum([(A[i]-.5)//x for i in range(N)]) <= K
  
def binary_search2(func, n_min, n_max):
    left,right=n_min,n_max
    while right-left>1:
        middle = (left+right)//2
        y_middle = func(middle)
        if y_middle: right=middle
        else: left=middle

    return right
  
print(binary_search2(C, 0, max(A)+1))

Solution (Python):
N,K=map(int,input().split())
*A,=map(int,input().split())

def C(x):
  return sum([(A[i]+x-1)//x-1 for i in range(N)]) <= K
  
def binary_search2(func, n_min, n_max):
    left,right=n_min,n_max
    while right-left>1:
        middle = (left+right)//2
        y_middle = func(middle)
        if y_middle: right=middle
        else: left=middle

    return right
  
print(binary_search2(C, 0, max(A)+1))

Solution (Python):
f=lambda:map(int,input().split())
N,K=f()
A=list(f())

def isOK(X):
    if X<=0:
        return False
    return sum([-a//X*-1-1 for a in A])<=K


ok=10**10
ng=-1
while abs(ok-ng)>1:
    mid=(ok+ng)//2
    if isOK(mid):
        ok=mid
    else:
        ng=mid
print(ok)

Solution (Python):

def fun(X_high, X_low, K, line):
    X = (X_high + X_low) // 2
    cnt = 0
    for tree in line:
        if tree <= X:
            continue
        else:
            q, r = divmod(tree, X)
            if r == 0:
                q -= 1
            cnt += q
    if cnt > K:
        X_low = X
    else:
        X_high = X
    return X_high, X_low

N, K = map(int, input().split(" "))
line = list(map(int, input().split(" ")))

X_high = max(line)
X_low = 0

while (X_high - X_low) > 1:
    X_high, X_low = fun(X_high, X_low, K, line)
    
print(X_high)

Solution (Python):
import math

n,k = (int(x) for x in input().split())
An = [int(i) for i in input().split()]

left = 0
right = max(An)

def check(x):
    chk = 0
    for i in range(n):
        chk += math.ceil(An[i]/x)-1
    return chk

while right-left!=1:
    x = (left+right)//2
    if check(x)<=k:
        right = x
    else:
        left = x

print(right)

Solution (Python):
import numpy as np

N, K = [int(x) for x in input().split()]
A = np.array([int(x) for x in input().split()])
I = np.array([1] * N)

L = np.max(A)

ans = L
low = 1
high = L
while 1:
    if low == high:
        ans = low
        break
    
    mid = (low + high) // 2
    if np.sum((A - I) // mid) <= K:
        high = mid
    else:
        low = mid + 1

print(ans)

Solution (Python):


n, k = map(int, input().split())
a_l = [int(x) for x in input().split()]

left = 0
right = max(a_l)


def cut(len):
    ret = 0
    for i in range(n):
        if a_l[i] % len == 0:
            ret += a_l[i] // len - 1
        else:
            ret += a_l[i] // len
    return ret


while (right - left) > 1:
    _q = (left + right) // 2
    _ret = cut(_q)
    if k >= _ret:
        right = _q
    else:
        left = _q

print(right)

Solution (Python):
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

def f(length, ls):
    cur = 0
    for a in ls:
        if a%length == 0:
            cur += a//length - 1
        else:
            cur += a//length
    if cur <= K:
        return True
    else:
        return False

ok, ng = max(A), 0
while abs(ok - ng) > 1:
    z = (ok+ng)//2
    if f(z, A) == True:
        ok = z
    else:
        ng = z
print(ok)

Solution (Python):
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))

l = 0
r = 10**9
while r - l > 1:
    m = (l+r) // 2
    cnt = 0
    for i in a:
        cnt += math.ceil(i / m) - 1
    if cnt <= k:
        r = m
    else:
        l = m
print(l+1)

Solution (Python):
N,K = map(int,input().split())
A = list(map(int,input().split()))

def check(m):
    n = 0
    for a in A:
        if a%m == 0:
            n += a//m - 1
        else:
            n += a//m
    return n <= K
        

l = 0
r = 10**9+10

while r-l > 1:
    m = (r+l) // 2
    if check(m):
        r = m
    else:
        l = m

print(r)

Solution (Python):

import sys
from itertools import chain


def cut_count(A, m):
    """最長の長さ(切り上げ)がm以下になるような切断回数"""
    total = 0
    for a in A:
        n = (a - 1) // m
        total += n
    return total


def solve(N: int, K: int, A: "List[int]"):
    r = max(A)
    l = 0
    while l + 1 < r:
        m = (r + l) // 2
        if cut_count(A, m) <= K:
            r = m  
        else:
            l = m  
    
    return r


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    
    N = int(next(tokens))  
    K = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    answer = solve(N, K, A)
    print(answer)


if __name__ == "__main__":
    main()

Solution (Python):

import numpy as np


def solve(*args: str) -> str:
    n, k = map(int, args[0].split())
    A = np.array(tuple(map(int, args[1].split())))

    l, r = 0, np.max(A)
    while l+1 < r:
        m = (l+r)//2
        if k < np.sum(np.ceil(A/m)-1):
            l = m
        else:
            r = m

    return str(r)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Solution (Python):

import numpy as np


def solve(*args: str) -> str:
    n, k = map(int, args[0].split())
    A = np.array(tuple(map(int, args[1].split())))

    l, r = 0, np.max(A)
    while l+1 < r:
        m = (l+r)//2
        if k < np.sum(-(-A//m)-1):
            l = m
        else:
            r = m

    return str(r)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Solution (Python):


def solve(*args: str) -> str:
    n, k = map(int, args[0].split())
    A = tuple(map(int, args[1].split()))

    l, r = 0, max(A)
    while l+1 < r:
        m = (l+r)//2
        cnt = 0
        for a in A:
            cnt += -(-a//m)-1

        if k < cnt:
            l = m
        else:
            r = m

    return str(r)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Solution (Python):


def solve(*args: str) -> str:
    n, k = map(int, args[0].split())
    A = tuple(map(int, args[1].split()))

    l, r = 1, max(A)
    while 0.1 < r-l:
        m = (l+r)/2
        cnt = 0
        for a in A:
            cnt += -int(-a//m)-1

        if k < cnt:
            l = m
        else:
            r = m

    return str(-int(-l//1))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Solution (Python):



N,K = map(int,input().split())
A = list(map(int,input().split()))



l,r = 0, 10**9


while r - l > 1:
    
    x = (r+l) // 2

    
    c = 0
    for a in A:
        
        c += (a-1) // x 

    
    if c <= K:
        r = x
    else:
        l = x
    
print(r)

Solution (Python):
n, k = map(int, input().split())
log = list(map(int, input().split()))

left = 0
right = 10**9

while right - left > 1:
  
  mid = (left + right) // 2
  
  cut = 0
  for i in range(n):
    cut += -(log[i]//-mid)-1

  if cut > k:
    left = mid
  else:
    right = mid
    
print(right)

Solution (Python):
n,k=map(int,input().split())
a=list(map(int,input().split()))
ng=0
ok=10**10
while ok-ng>1:
  m=(ok+ng)//2
  c=0
  for i in a:
    c+=(i//m-(i%m==0))
  if c<=k:
    ok=m
  else:
    ng=m
print(ok)

Solution (Python):
import sys



def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    ng = 0
    ok = 10 ** 9 + 1

    while ok - ng > 1:
        mid = (ok + ng) // 2
        ans=0
        for i in A:
            a,b =divmod(i,mid)
            ans +=a-1
            if b!=0:
                ans+=1
            if ans >K:
                break

        if ans <= K:
            ok = mid
        else:
            ng = mid

    print(ok)


if __name__ == "__main__":
    main()

Solution (Python):
import sys



def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    ng = 0
    ok = 10 ** 9 + 1

    while ok - ng > 1:
        mid = (ok + ng) // 2
        ans =0
        for i in range(N):
            ans += A[i]//mid -1
            if A[i]%mid !=0:
                ans +=1
            if ans >K:
                break

        if ans <= K:
            ok = mid
        else:
            ng = mid

    print(ok)


if __name__ == "__main__":
    main()

Solution (Python):
import sys



def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    ng = 0
    ok = 10 ** 9 + 1
    A.sort(reverse=True)

    while ok - ng > 1:
        mid = (ok + ng) // 2
        ans =0
        for i in range(N):
            ans += A[i]//mid -1
            if A[i]%mid !=0:
                ans +=1
            if ans >K:
                break

        if ans <= K:
            ok = mid
        else:
            ng = mid

    print(ok)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
import math


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    ng = 0
    ok = 10 ** 9 + 1

    while ok - ng > 1:
        mid = (ok + ng) // 2
        ans = sum(list(map(lambda x: math.ceil(x / mid) - 1, A)))

        
        
        
        

        if ans <= K:
            ok = mid
        else:
            ng = mid

    print(ok)


if __name__ == "__main__":
    main()