peterverebics/CodeNet_Python_118 huggingface dataset:
n,k=map(int,input().split())
arr=list(map(int,input().split()))
if(k==0):
	print(max(arr))
else:
	low=1
	high=1000000000
	while(low<=high):
		mid=low+(high-low)//2
		if(mid==1):
			print(mid)
			break
		count=0
		count2=0
		for i in range(n):
			count+=(arr[i]-1)//mid
			count2+=(arr[i]-1)//(mid-1)
		if(count==k and count2==k+1):
			print(mid)
			break
		elif(count<k or (count==k and count2!=k+1)):
			high=mid-1
		else:
			low=mid+1
N,K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
M = max(A)
m = 1
mid = M//2
while m<M:
  n = 0
  for a in A:
    n += -(-a//mid)-1
    if n > K:
      m = mid+1
      break
  else:
    M = mid
  mid = (M+m)//2
print(mid)
import bisect
N,K=map(int,input().split())
A=list(map(int,input().split()))

#全ての丸太を長さt以下にするのに必要な切断数が
#k以下であるような最大のtを求める
ok=max(A)
ng=0

def isok(t):
  res=0
  for i in range(N):
    res+=A[i]//t
  return res<=K

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

print(ok)
#!/usr/bin/env python3
from math import ceil

EPS = 1e-8
n, k = map(int, input().split())
a = list(map(int, input().split()))


def f(p):
    c = 0
    for x in a:
        c += x // p
    return c


ok, ng = 0, max(a)
while abs(ok - ng) > 1:
    m = (ok + ng) / 2
    if f(m) > k:
        ok = m
    else:
        ng = m
print(ceil(ok))
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)
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))

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

ok = 1
ng = max(A)+1

while abs(ok-ng) > 1:
    mid = (ok+ng)//2
    
    cnt = 0
    for a in A:
        y = math.ceil(a/mid)
        cnt += y-1

    if cnt <= K:
        ng = mid
    else:
        ok = mid+1
    

print(ok)
import math

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

left=a[0]
right=a[n-1]
mid = (left+right)/2
while right - left > 1:
    times = 0
    for i in range(n):
        times+=math.ceil(a[i]/mid)-1
    if times<=k:
        right=mid
        mid=(left+right)/2
    else:
        left = mid
        mid =(left+right)/2

print(math.ceil(mid))
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,k=mp()
a=sorted(lmp())
ans=10**10
l=1
r=a[-1]
while True:
    if l==r-1:
        print(r)
        exit()
    m=(l+r)//2
    c=0
    for i in a:
        c+=-(-i//m)-1
    if c>k:
        l=m
    else:
        r=m
#coding: utf-8
N, K = (int(n) for n in input().split())
A = [int(n) for n in input().split()]

def SplitTo(X):
    ret = 0
    for log in A:
        ret += -(-log//X) - 1
    return ret

l = 1 
r = max(A) 
mid = 0

while l <= r:
    mid = (l+r) // 2
    ret = SplitTo(mid)
    yes = ret <= K
    if yes:
        r = mid - 1
    else:
        l = mid + 1

print(mid)
def check(lis,k,mid):
	for i in lis:
		k-=(i//mid)
	return k>=0
n,k=map(int,input().split())
lis=list(map(int,input().split()))
a,b=1,max(lis)
ans=b
while(a<=b):
	mid=(a+b)//2
	if(check(lis,k,mid)):
		ans=mid
		b=mid-1
	else:
		a=mid+1
print(ans)
from math import ceil, floor


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    lower = 1
    upper = a[-1]
    while upper - lower >= 1:
        target = (lower + upper) / 2
        now = 0
        for i in range(n):
            now += ceil(a[i] / target) - 1
        if now > k:
            lower = target + 1
        else:
            upper = target
    print(floor(lower) if k > 0 else a[-1])


if __name__ == '__main__':
    main()
import heapq
import math
N,K = map(int,input().split())
a = list(map(int,input().split()))
h = math.ceil(sum(a)/(K+N))

if N<K:
    print(h)
else:
    a = list(map(lambda x:x*(-1), a))
    heapq.heapify(a)    
    for i in range(K):
        m = heapq.heappop(a)
        heapq.heappush(a, h) 
        heapq.heappush(a, m -h)
    res =  heapq.heappop(a) * -1
    print(math.ceil(res))
import math

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

def binary_search(ng=1, ok=max(a)):
    if ok - ng < 2: return ok
    mid = (ok + ng) // 2
    cnt = 0
    for i in a:
        cnt += math.ceil(i / mid) - 1
    if cnt <= k:
        return binary_search(ng, mid)
    else:
        return binary_search(mid, ok)
print(binary_search())
import sys
import math

input = sys.stdin.readline

def can(arr, m, K):
  need = 0
  for x in arr:
    need += int(x // m)
  return need <= K


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

lo = 0.0
hi = 1e9

for i in range(25):
  m = (lo + hi) / 2.0
  if (can(arr, m, K)):
    hi = m
  else:
    lo = m
ans = lo

print(int(math.ceil(lo)))
from math import ceil
from fractions import Fraction
from sys import exit
import heapq

n,k, *aa = map(int, open(0).read().split())

left = 1
right = sum(aa)
mid = (left + right) // 2

while right - left > 1:
    summ = sum((a-1)//mid for a in aa)
    if summ <= k:
        right = mid
        mid = (left + right) // 2
    else:
        left = mid
        mid = (left + right) // 2

print(right)
n,k =  map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
print(A)

for i in range(k):
    
    
    A[0] /= 2
    A.sort(reverse=True)

print(int(A[0]))
import math
n,d = map(int, input().split(' '))
cirs = list(map(int, input().split(' ')))

if n == 1:
  print(math.ceil(cirs[0]/(2**d)))
else:
  for _ in range(d):
    list.sort(cirs, reverse=True)
    first = cirs[0]
    if len(cirs) == cirs.count(first):
      second = cirs[1]
    else:
      second = sorted(set(cirs), reverse=True)[1]
    # firstの削除
    cirs.remove(first)
    if first/2 < second:
      cirs.extend([second, first-second])
    else:
      cirs.extend([first/2, first/2])
print(math.ceil(max(cirs)))
import heapq
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

low = 0
high = 10**9

if k == 0:
    print(max(a))
    exit()

    
while low+1 < high:
    tmp = 0
    mid = (low + high) //2
    
    for i in range(n):
        tmp += ((a[i]+mid-1) // mid)-1
        
    print(tmp,mid)
    
    if tmp <= k:
        high = mid
    else:
        low = mid
        
print(high)
n,k = list(map(int,input().split()))
f = list(map(int,input().split()))

s = (10**9) // 2
step = s
best= 999999999999
import math

for j in range(50):
  c = 0
  arr = list(f)
  for i in range(n):
    c += arr[i] // s
    cor = 0
    if arr[i] % (c+1) != 0:
      cor = 1
    arr[i] = arr[i]//(c+1) + cor
    
  step = step//2
  step = max(1, step)
 
  if c<=k:
    s -= step
    best = min(best,max(arr))
  else:
    s += step
    
  if s==0:
    s=1
      
print(best)
N,K=[int(s) for s in input().split()]
maruta=[int(s) for s in input().split()]

def possible(x):
  cut=0
  for e in maruta:
    cut+=e//x
  if cut<=K:
    return True
  else:
    return False

a=1
b=max(maruta)
while b-a>1:
  c=(a+b)//2
  if possible(c):
    b=c
  else:
    a=c

if a==1 and possible(1):
  print(1)
else:
  print(b)
from math import floor
N, K = map(int,input().split())
A = list(map(int,input().split()))
def chk(L):
    cnt = 0
    for i in range(N):
        cnt += floor(A[i]/L)
    return cnt <= K
l, r = 1, max(A)
for _ in range(10000):
    m = (l+r)/2
    if chk(m):
        r = m
    else:
        l = m
print(round(m))
n, k = map(int, input().split())
A = list(map(int, input().split()))
r = max(A)
l = 0
while l + 1 < r:
    mid = (l + r) // 2
    if sum([(a - 1) // mid for a in A]) >= k:
        l = mid
    else:
        r = mid

print(l)
import heapq

length_heap = []

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

for l in input().split():
    heapq.heappush(length_heap, (-int(l), 1))

for i in range(total_cut):
    longest, cut_n = heapq.heappop(length_heap)
    heapq.heappush(length_heap, ((longest * cut_n)/(cut_n + 1), (cut_n + 1)))

result = -heapq.heappop(length_heap)[0]

print(int(result+0.5))
N, K = map(int,input().split())
A = sorted(map(int,input().split()))
start = 0
end = A[-1]
l = (start + end)/2
while int(end) - start >= 1:
   l = (start + end)/2
   count = 0
   for i in range(N):
      q, mod = divmod(A[i], l)
      if mod == 0.0:
         q -= 1
      count += q
   if count > K:
      start = l
   else:
      end = l
ans = (start + end)/2
print(int(end)+1)
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))

l = 1
r = 10**9 + 1
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)
n, k = map(int, input().split())
a = list(map(int, input().split()))

def c(x):
    cnt=0
    for i in a:
        cnt += i // x
    return cnt <= k
    
l, r = 0, max(a) + 1
while l + 1 < r:
    mid = (l + r) // 2
    if c(mid):
        r = mid
    else:
        l = mid

print(r)
N,K = map(int,input().split())
A = list(map(int,input().split()))
L = 0
R = max(A)
while R-L > 0.001:
    X = (L+R)/2
    m = 0
    for i in range(N):
        c = A[i]/X
        if c == int(c):
            m += int(c) - 1
        else:
            m += int(c)
    if m <= K:
        R = X
    else:
        L = X
print(int(R))
import math

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

l = 1
r = 10**9
while(r-l > 1):
  mid = int(l + (r-l)/2)
  cut = 0
  for num in nums:
    cut += math.ceil(num/mid)-1
  if cut <= K:
    r = mid
  else:
    l = mid
print(r)
N, K = map(int, input().split())
A = list(map(int, input().split()))

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

ok = max(A)
ng = 0
while ok - ng > 1:
    mid = (ok + ng) // 2
    if isOk(mid):
        ok = mid
    else:
        ng = mid

while ok > 1 and isOk(ok - 1):
    ok -= 1

print(ok)
N, K = map(int, input().split())
arr = list(map(int, input().split()))
def f(x):
    res = 0
    for i in range(N):
        res += arr[i]//x
    return res
left = 0
right = max(arr)
while abs(left-right) > 1:
    tmp = (left+right)//2
    if f(tmp) > K:
        left = tmp
    else:
        right = tmp
print(right)
import math


N, K = map(int, input().split())
logs = list(map(int, input().split()))
longest_log = max(logs)

if K == 0:
    print(longest_log)
    exit()

def count_cut(log, size):
    return log//size

left, right = 1, longest_log

while left <= right:
    pivot = left + (right - left) // 2
    count = sum(count_cut(log, pivot) for log in logs)
    if left == right:
        break
    if count > K:
        left = pivot + 1
    elif count <= K:
        right = pivot - 1

print(pivot)
import math
import heapq
from collections import deque
a = []
heapq.heapify(a)
N,K=map(int,input().split())
if K>=N*30+1:
    print(1)
else:
    L=list(map(int,input().split()))
    for i in range(N):
        heapq.heappush(a,(-L[i],1)) 
    for i in range(K):
        b,count=heapq.heappop(a)
        b=b*count/(count+1)
        heapq.heappush(a,(b,count+1))
    b,count=heapq.heappop(a)
    print(math.ceil(-b))
def check(List,mid):
    tmp=0
    for l in List:
        tmp+=(-(-l//mid)-1)
    return tmp

n,k=map(int,input().split())
a=list(map(int,input().split()))
lo=1
hi=max(a)
while hi - lo > 1:
    mid=(lo+hi)//2
    if check(a,mid)<=k:
        hi=mid
    else:
        lo=mid
print(hi)
n, k = map(int, input().split())
a = list(map(int, input().split()))

def c(x):
    cnt=0
    for i in a:
        cnt += i // x
    return cnt <= k
    
l, r = 0, 10**9
while l + 1 < r:
    mid = (l + r) // 2
    if c(mid):
        r = mid
    else:
        l = mid

print(r)
import copy
import math

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

ub = 10**9
lb = 0

while ub - lb > 10**-6:
    x = (ub + lb) / 2
    cnt = 0
    for i in a:
        cnt += math.ceil(i/x)
    if cnt <= n+k:
        ub = copy.deepcopy(x)
    else:
        lb = copy.deepcopy(x)
ans = round(ub, 5)
print(math.ceil(ans))
import math

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

floor = 1
ceil = max(a)


def cut(long, logs):
    cnt = 0
    for i in logs:
        cnt += math.ceil(i / long) - 1
    return cnt


while ceil - floor > 1:
    L = (ceil + floor)//2
    num = cut(L, a)
    if num <= k:
        ceil = L
    else:
        floor = L

print(ceil)
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))

l = 1
r = max(a)
mid = (r+l)//2
while not r-l == 1:
    c = 0
    for x in a:
        c += x//mid
    if c > k:
        l = mid
    else:
        r = mid
    mid = (r+l)//2
c = 0
for x in a:
    c += x//l
if c > k:
    print(r)
else:
    print(l)
import math

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

m = 0
M = max(A)

while(M-m>0.0001):
    mm = 0

    mid = (M+m)/2
    for i in range(N):
        mm += math.ceil(A[i]/mid)-1

    if mm>=K:
        m = mid
    else:
        M = mid

print(math.ceil(mid))
N, K = map(int, input().split())
tree = list(map(int, input().split()))
left = 0
treeLen = len(tree)
right = max(tree)
while right - left > 1:
    cnt = 0
    mid = (right + left) // 2
    for i in range(treeLen):
        cnt += tree[i] // mid
    if K >= cnt:
        right = mid
    else:
        left = mid
print(right)
n, k = map(int, input().split())
a = list(map(int, input().split()))
result = max(a)
# a = [x * 2 for x in a]
left = 1
right = result
med = left + (right - left) // 2
while left <= right:
    counter = sum([x // med for x in a])
    if counter <= k:
        result = med
        right = med - 1
    else:
        left = med + 1
    med = left + (right - left) // 2
print(result)
from math import ceil
from fractions import Fraction
from sys import exit
import heapq

n,k, *aa = map(int, open(0).read().split())

left = 1
right = sum(aa)
mid = (left + right) // 2

while right - left > 1:
    summ = sum(0--a//mid-1 for a in aa)
    if summ <= k:
        right = mid
        mid = (left + right) // 2
    else:
        left = mid
        mid = (left + right) // 2

print(right)
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 14 13:43:55 2020

@author: ezwry
"""
import math

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

logmin = math.ceil(sum(alist) / (n + k))
logmax = max(alist)


def howmanytimes(t, m):
    x = math.ceil(t/m) - 1
    return x


for i in range(logmin, logmax + 1):
    kaisu = 0
    for j in range(len(alist)):
        z = howmanytimes(alist[j], i)
        kaisu += z
    if kaisu == k:
        print(i)
        exit()
import math

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

left = 0
right = A[0]

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

print(right)
from math import ceil

m=1
M=10**9

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

def OK(k):
    if sum([ceil(a/k) for a in A])<=K:
        return True
    else:
        return False

while M-m>1:
    p=(m+M)//2
    if OK(p):
        m=p
    else:
        M=p
print(m)
N,K=map(int,input().split())
L=list(map(int,input().split()))
if K>=10**7:
    print(1)
    exit()
    
import heapq

Q=[]
for i in range(N):
    Q.append((-L[i],L[i],1))
heapq.heapify(Q)

for i in range(K):
    l,B,cnt=heapq.heappop(Q)
    heapq.heappush(Q,(-B/(cnt+1),B,cnt+1))
#print(Q)
#print(Q[0][0])

import math
ans=-Q[0][0]
print(math.ceil(ans))
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
b = sum(a)

ans = 0
nokori = k
for i, j in enumerate(a):
    if nokori == 0:
        break
    tmp = (j * k + b - 1) // b
    if nokori - tmp >= 0:
        ans = max(ans, (j + tmp) // (tmp + 1))
    else:
        ans = max(ans, (j + nokori) // (nokori + 1))
        break
    nokori -= tmp

if k == 0:
    print(a[0])
else:
    print(ans)
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
from math import ceil
def main(N, K, A):
    def cut_times(longest):
        return sum(a // longest for a in A)
    under = -1
    r = 10**9
    for i in range(100):
        m = (under + r) / 2
        if cut_times(m) <= K: r = m
        else: under = m
    print(ceil(r))

if __name__ == '__main__':
    input = sys.stdin.readline
    N, K = map(int, input().split())
    *A, = map(int, input().split())
    main(N, K, A)
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, 1, max(A)))
import sys
input = sys.stdin.readline
N,K = map(int,input().split())
A = list(map(int,input().split()))

x = max(A)

mn = 0
mx = max(A)

while mx-mn > 1:
    suc = True
    cnt = 0
    for a in A:
       cnt += -(-a)//x
       if cnt > K:
           suc = False
           break
    if suc:
        mx = x
        x = (mn+mx)//2+1
    else:
        mn = x
        x = (mn+mx)//2

print(x)
import math

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

s = sum(a)

for i in range(n):
    t = round(k * a[i] / s)
    a[i] = math.ceil(a[i] / (t + 1))

print(max(a))
import math

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

def is_ok(x,a,k):
    b = 0
    for ai in a:
        b += math.ceil(ai/x)
        b -= 1
    print(x,b)
    if b <= k:
        return True

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


print(meguru_bisect(0,max(a)))
(N,K) = map(int,input().split())
l = input().split()
max = 0
for i in range(N):
    l[i]= int(l[i])
    if max <= l[i]:
        max = l[i]

lb = 1
ub = max

def cut(m):
    k = 0
    for i in range(N):
        k += -((-1*l[i])//m)-1
    return k

while ub - lb > 1:
    if cut((ub+lb)//2)>K:
        lb = (ub+lb)//2
    else:
        ub = (ub+lb)//2

print(ub)
import math
import numpy as np
a = list(map(int, input().split()))
b = list(map(int, input().split()))

for i in range(0,a[1]):
    b[np.argmax(b)] = b[np.argmax(b)] / 2

print(math.ceil(max(b)))
from math import ceil
n, k, *A = map(int, open(0).read().split())
t = sum(A) / (n+k)
A = [a for a in A if int(a/t) >= 1]
X = []
for a in A:
    X.append(ceil(a / ceil(a/t)))
    X.append(ceil(a / int(a/t)))
X.sort()
print(X[k] if k < len(X) else X[-1])
from math import ceil
n,k=map(int,input().split())
lst=list(map(int,input().split()))
ng=1
ok=10**9+1
while ok-ng>1:
    mid=(ok+ng)//2
    tmp=0
    for i in range(n):
        tmp+=ceil(lst[i]/mid)-1
    if tmp>k:
        ng=mid
    else:
        ok=mid
print(ok)
import math
n, k = map(int, input().split())
A = list(map(int, input().split()))

max_len = max(A)
def f(x):
    ans = 0
    for a in A:
        cut_num = math.ceil(a / x) - 1
        #print(a, cut_num, a / x)
        ans += cut_num
    if ans <= k:
        return True
    else:
        return False

left = 1
right = max_len
while right - left > 1:
    mid = (right + left) // 2
    if f(mid):
        right = mid
    else:
        left = mid
else:
    print(right)
import math
N, K=map(int,input().split())
A=list(map(int,input().split()))

def judge(ans,K,A):
    cut=0
    for i in range(len(A)):
        cut+=A[i]//ans
    if cut>K:
        return False
    else:
        return True


ansp=max(A)
ansm=min(A)
ans=(ansp+ansm)//2
d=1
while ansp-ansm>d:
    
    if judge(ans,K,A):
        ansp=ans
        
    else:
        ansm=ans
        
    ans=(ansp+ansm)//2
print(ansp)
# coding: utf-8
import math
n,k = map(int,input().split())
log_list = list(map(float,input().split()))
log_list.sort()

cut_count = 0
while cut_count < k:
    max_index = log_list[n-1]
    next_index = log_list[n-2]
    div_count = 2
    while(log_list[n-1] / div_count >= log_list[n-2]):
        div_count+=1
    log_list[n-1] = log_list[n-1] / div_count
    cut_count += div_count - 1
    log_list.sort()

print(log_list)
print(math.ceil((max(log_list))))
import math
N,K = map(int,input().split())
cs = list(map(int, input().split()))
ma = max(cs)
mi = 0
rgl = math.ceil(math.log2(ma))
rt = ma+1
def counter(ch,mo):
  rt =math.ceil(ch/mo)
  return rt-1 if rt > 0 else 0

for _ in range(rgl):
  cnt = 0
  for c in cs:
    cnt+=counter(c,ma)
  if cnt <= K and ma < rt:
    rt = ma
    ma = math.ceil((ma+mi)/2)
  else:
    tmp = ma
    ma += math.ceil((ma-mi)/2)
    mi = tmp

print(rt)
from math import ceil

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, 1, max(A)))
import math

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

def is_ok(mid):
    cnt = 0
    for i in range(N):  cnt += math.floor(A[i] / mid)
    return cnt <= K

def binary_search(left, right):
    while (abs(right - left) > 1):
        mid = (left + right) // 2
        if is_ok(mid):  right = mid
        else:  left = mid
    return right

if K == 0:  print(max(A))
else:
    left = max(A)
    right = 0
    ret = binary_search(right, left)
    print(ret)
def is_ok(X):
    cnt = 0
    for a in A:
        cnt += a//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)))
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
X = max(A)
if K == 0:
    print(X)
    exit()
else:
    for i in range(1, 32):
        B = []
        for a in A:
            b = math.ceil(a / X) - 1
            B.append(b)
        B_total = sum(B)
        if B_total > K:
            X += max(A) / pow(2, i)
        else:
            X -= max(A) / pow(2, i)
    print(math.ceil(X))
from heapq import heappop, heappush, heapify 

n, x = map(int,input().split())
a = [-1*int(i) for i in input().split()]
ans = []
heapify(ans)
for i in a:
    heappush(ans, i)
while x > 0:
    t = -1*heappop(ans)
    t1,t2 = t//2,t//2+t%2
    heappush(ans, -t1)
    heappush(ans, -t2)
    x -= 1
print(-1*heappop(ans))
import math

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

left = 0
right = max(a)

while True:
  mid = (left + right) / 2
  
  cnt = 0
  for _a in a:
    cnt += math.ceil(_a / mid - 1)
  
  if cnt > k:
    left = mid
  else:
    right = mid
  
  if right - left <= 10 ** -3:
    break

print(math.ceil(left))
import heapq
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

low = 1
high = 10**9

if k == 0:
    print(max(a))
    exit()

if n == 1:
    print((a[0]+k)//(k+1))
    exit()
    
while low+1 < high:
    tmp = 0
    mid = (low + high) //2
    #print(mid)
    
    for i in range(n):
        tmp += ((a[i]+mid-1) // mid)-1
    
    if tmp <= k:
        high = mid
    else:
        low = mid
        
print(high)
from bisect import bisect_right

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

OK = 10**9
NG = 1

while OK - NG > 1:
    ans = 0
    mid = (OK+NG)//2
    temp = bisect_right(A, mid)
    if temp == N:
        OK = mid
    else:
        for a in A[temp::]:
            ans += a//mid
        if ans > K:
            NG = mid
        else:
            OK = mid
print(OK)