AtCoder Beginner Contest 174 - Logs

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-----
2 3
7 9

-----Sample Output-----
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.

Difficulty: MEDIUM

Starter code:

Solutions:
import sys
(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
(l, r) = (0, max(a))
while r - l > 1:
	t = (l + r) // 2
	c = sum([(e - 1) // t for e in a])
	if k < c:
		l = t
	else:
		r = t
print(r)


(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)


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] - 1) // ans
	if cut > K:
		return False
	else:
		return True
ansp = max(A)
ansm = 0
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)


import sys
input = sys.stdin.readline
(N, K) = map(int, input().split())
A = list(map(int, input().split()))
l = 0
r = 2 * 10 ** 9
while r - l > 1:
	m = (l + r) // 2
	count = 0
	for a in A:
		count += (a + m - 1) // m - 1
	if count <= K:
		r = m
	else:
		l = m
print(r)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = 0
r = max(a)
while r - l > 1:
	cnt = 0
	mid = (r + l) // 2
	for i in range(n):
		d = (a[i] - 1) // mid
		if d > 0:
			cnt += d
	if cnt <= k:
		r = mid
	else:
		l = mid
print(r)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
l = 0
r = max(arr)
while l + 1 < r:
	m = (l + r) // 2
	cut = 0
	for x in arr:
		cut += (x - 1) // m
	if cut > k:
		l = m
	else:
		r = m
print(r)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = 0
r = 10 ** 10
while r - l > 1:
	x = (l + r) // 2
	ct = 0
	for i in range(n):
		ct += (a[i] - 1) // x
	if ct <= k:
		r = x
	else:
		l = x
print(r)


import heapq
(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
ok = 10 ** 9
ng = 0
while abs(ng - ok) > 1:
	m = (ok + ng) // 2
	cou = 0
	for i in a:
		cou += (i + m - 1) // m - 1
	if cou <= k:
		ok = m
	else:
		ng = m
print(ok)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = 0
r = 1000000000.0 + 5
while l + 1 != r:
	m = (l + r) // 2
	cnt = 0
	for x in a:
		cnt += (x - 1) // m
	if cnt <= k:
		r = m
	else:
		l = m
print(int(r))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
max_l = 10 ** 9
min_l = 0
while max_l - min_l != 1:
	count = 0
	mean = (max_l + min_l) // 2
	for i in range(n):
		count += -(-a[i] // mean) - 1
	if count <= k:
		max_l = mean
	else:
		min_l = mean
print(max_l)


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)


def f(m):
	cut = 0
	for aa in a:
		cut += (aa - 1) // m
		if cut > k:
			return False
	return True
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = 0
r = 10 ** 9 + 1
while r - l > 1:
	m = (l + r) // 2
	if f(m):
		r = m
	else:
		l = m
print(r)


(n, k, *aa) = map(int, open(0).read().split())
imp = 0
psbl = 10 ** 9
while psbl - imp > 1:
	mid = (psbl + imp) // 2
	cost = sum((0 - -a // mid - 1 for a in aa))
	if cost <= k:
		psbl = mid
	else:
		imp = mid
print(psbl)


(N, K) = list(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)


import numpy as np

def solve(*args: str) -> str:
	(n, k) = list(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)

def __starting_point():
	print(solve(*open(0).read().splitlines()))
__starting_point()


import math
(n, k) = map(int, input().split())
A = list(map(int, input().split()))
low = 1
high = max(A)
while low != high:
	mid = (low + high) // 2
	s = 0
	for i in range(n):
		s += math.ceil(A[i] / mid) - 1
	if s > k:
		low = mid + 1
	else:
		high = mid
print(low)


from math import ceil
(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))
for i in range(100):
	mid = (l + r) / 2
	if c(mid):
		r = mid
	else:
		l = mid
print(ceil(l))


from math import floor, ceil
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
l = 0
r = max(a)
while r - l > 1:
	c = (l + r) // 2
	cnt = 0
	for i in a:
		cnt += max(ceil(i / c) - 1, 0)
	if cnt <= k:
		r = c
	else:
		l = c
print(r)


(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
l = 1
h = a[0]
while l != h:
	m = (l + h) // 2
	cut = 0
	for x in a:
		cut += x // m + (x % m != 0) - 1
	if cut <= k:
		h = m
	else:
		l = m + 1
print(l)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = 0
r = max(a)
while r - l > 1:
	c = (l + r) // 2
	t = 0
	for ai in a:
		t += (ai + c - 1) // c - 1
	if t <= k:
		r = c
	else:
		l = c
print(r)


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
M = max(A)
(l, r) = (1, M)
cnt = 0
while l <= r:
	cnt = 0
	mid = (l + r) // 2
	for a in A:
		tmp = a // mid if a > mid else 0
		cnt += tmp
	if cnt <= k:
		r = mid - 1
	else:
		l = mid + 1
print(l)


import math
(N, K) = list(map(int, input().split()))
A = list(map(int, input().split()))
(l, r) = (A[0], 1)

def is_ok(c):
	x = sum([math.ceil(a / c) - 1 for a in A])
	return x <= K
(l, r) = (max(A), 0)
while l - r > 1:
	c = (l + r) // 2
	if is_ok(c):
		l = c
	else:
		r = c
print(l)


def f(x):
	return sum([(i - 1) // x for i in a]) <= k

def main():
	(l, r) = (0, 10 ** 9)
	while r - l > 1:
		m = (l + r) // 2
		if f(m):
			r = m
		else:
			l = m
	print(r)
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
main()


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
left = 0
right = 10 ** 10
while right - left > 1:
	cut = 0
	mid = left + (right - left) // 2
	for a in A:
		cut += (a + mid - 1) // mid - 1
	if cut <= K:
		right = mid
	else:
		left = mid
print(right)


(N, K) = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
M = max(A)
m = 1
mid = (M + 1) // 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)


(n, k) = map(int, input().split())
A = list(map(int, input().strip().split()))
b = 0
e = max(A)
L = e // 2
while e - b > 1:
	L = (e + b) // 2
	m = sum(list(map(lambda x: (x - 1) // L, A)))
	if m <= k:
		e = L
	else:
		b = L
print(e)


def judge(A, x, k):
	ans = 0
	for a in A:
		ans += a // x
		if a % x == 0:
			ans -= 1
		if ans > k:
			return False
	return True
(n, k) = map(int, input().split())
A = list(map(int, input().split()))
l = 0
r = max(A)
while r - l != 1:
	x = (r + l) // 2
	if judge(A, x, k):
		r = x
	else:
		l = x
print(r)


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)

def __starting_point():
	main()
__starting_point()


def check(x):
	ret = 0
	for e in a:
		ret += max((e - 1) // x, 0)
	return ret <= k
(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
	if check(m):
		r = m
	else:
		l = m
print(r)


(n, k) = map(int, input().split())
A = [int(i) for i in input().split()]
ng = 0
ok = max(A)
while ng + 1 != ok:
	mid = (ok + ng) // 2
	ans = 0
	for i in A:
		ans += 0 - -i // mid - 1
	if ans <= k:
		ok = mid
	else:
		ng = mid
print(ok)


(N, K) = map(int, input().split())
X = list(map(int, input().split()))
ub = 10 ** 9 + 7
lb = 0
while ub - lb > 1:
	mid = (ub + lb) // 2
	cnt = 0
	for v in X:
		cnt += -(-v // mid) - 1
	if cnt <= K:
		ub = mid
	else:
		lb = mid
print(ub)


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)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = 0
r = max(a) + 1
while r - l > 1:
	cnt = 0
	mid = (l + r + 1) // 2
	if mid == 0:
		print(1)
		exit()
	for x in a:
		if x > 1:
			cnt += (x - 1) // mid
	if cnt <= k:
		r = mid
	else:
		l = mid
print(r)


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

def f(x):
	return sum(((a + x - 1) // x - 1 for a in A))
l = 0
r = 10 ** 9 + 1
while r - l > 1:
	mid = (l + r) // 2
	if f(mid) <= K:
		r = mid
	else:
		l = mid
print(r)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
l = 0
r = 10 ** 9
while r - l > 1:
	m = (r + l) // 2
	count = 0
	for i in A:
		if i > m:
			count += i // m
	if count > K:
		l = m
	else:
		r = m
print(r)


(n, k) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
(low, high) = (0, max(arr) + 1)
while high - low > 1:
	mid = (high + low) // 2
	curr = 0
	for i in arr:
		curr += (i - 1) // mid
	if curr > k:
		low = mid
	else:
		high = mid
print(high)


(n, k) = map(int, input().split())
A = tuple(map(int, input().split()))
A = sorted(A, reverse=True)
l = 0
r = max(A) + 1

def cut(l, k):
	for a in A:
		if a > l:
			k -= -(-a // l) - 1
	return k >= 0
while r - l > 1:
	mid = (r + l) // 2
	if cut(mid, k):
		r = mid
	else:
		l = mid
print(r)


(N, K) = list(map(int, input().split()))
A = list(map(int, input().split()))
l = 0
r = max(A)
while l + 1 < r:
	m = (l + r) // 2
	n = sum([(x - 1) // m for x in A])
	if n > K:
		l = m
	else:
		r = m
print(r)


(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)


def main():
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	(L, R) = (0, max(arr))
	while L + 1 < R:
		P = (L + R + 1) // 2
		cnt = 0
		for a in arr:
			if P < a:
				if a % P == 0:
					cnt += a // P - 1
				else:
					cnt += a // P
		if cnt <= k:
			R = P
		else:
			L = P
	print(R)

def __starting_point():
	main()
__starting_point()


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
ok = 1001001001
ng = 0

def check(x):
	cnt = 0
	for q in a:
		cnt += (q - 1) // x
	return cnt <= k
while ok - ng > 1:
	mid = (ok + ng) // 2
	if check(mid):
		ok = mid
	else:
		ng = mid
print(ok)


from math import ceil
(N, K) = map(int, input().split())
A = list(map(int, input().split()))

def chk(L):
	cnt = 0
	for i in range(N):
		cnt += ceil(A[i] / L) - 1
	return cnt <= K
(l, r) = (1, max(A))
while l <= r:
	m = (l + r) // 2
	if chk(m):
		r = m - 1
	else:
		l = m + 1
print(min([x for x in [m - 1, m, m + 1] if x > 0 and chk(x)]))


from math import *
f = lambda : [*map(int, input().split())]
(n, k) = f()
a = f()

def ok(x):
	c = 0
	for i in a:
		c += ceil(i / x)
	return c <= n + k
(l, r) = (0, 10 ** 9 + 1)
while r - l > 0.1:
	m = (l + r) / 2
	if ok(m):
		r = m
	else:
		l = m
t = ceil(r)
print(t - ok(t - 1) if t > 1 else t)


(n, k) = map(int, input().split())
(*a,) = map(int, input().split())
mx = max(a)
mn = 10 ** (-9)
from math import ceil
while mx - mn > 10 ** (-5):
	md = (mx + mn) / 2
	cnt = 0
	for ai in a:
		cnt += ceil(ai / md) - 1
	if cnt <= k:
		mx = md
	else:
		mn = md
print(ceil(mn))


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


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
import math
x = 0
y = 10 ** 9
z = 5 * 10 ** 8
s = 0
for i in range(100):
	t = 0
	for j in range(n):
		t += a[j] // z
	if t <= k:
		s = t
		y = z
		z = (x + y) / 2
	else:
		x = z
		z = (x + y) / 2
print(math.ceil(z))


def is_ok(x):
	sum = 0
	for i in range(n):
		sum += (a[i] + x - 1) // x - 1
	if sum <= 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()))
if is_ok(1):
	print(1)
	return
print(meguru_bisect(1, int(10000000000.0)))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
(l, r) = (1, 10 ** 9)
while l < r:
	m = (l + r) // 2
	if sum(map(lambda v: (v - 1) // m, a)) > k:
		l = m + 1
	else:
		r = m
print(l)


import math
(N, K) = map(int, input().split())
A = list(map(int, input().split()))
mini = 0
maxi = max(A)
while maxi - mini > 1:
	mid = (maxi + mini) // 2
	s = sum((math.ceil(a / mid) - 1 for a in A))
	if s > K:
		mini = mid
	else:
		maxi = mid
print(mini + 1)


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)


import math
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
(x0, x1) = (0, 10 ** 9)
while x0 + 1 < x1:
	x = (x0 + x1) // 2
	suma = 0
	for i in a:
		if i % x == 0:
			suma += i // x - 1
		else:
			suma += i // x
	if suma > k:
		x0 = x
	else:
		x1 = x
print(x1)


(N, M) = input().strip().split()
(n, k) = [int(N), int(M)]
a = list(map(int, input().strip().split()))
le = 0
ri = 10000000000
while ri - le > 1:
	mid = (le + ri) // 2
	num = 0
	for i in a:
		num += (i - 1) // mid
	if num <= k:
		ri = mid
	else:
		le = mid
print(ri)


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
l = 0
r = 10 ** 9
while l + 1 < r:
	m = (l + r) // 2
	cnt = 0
	for i in range(n):
		cnt += (a[i] + m - 1) // m - 1
	if cnt > k:
		l = m
	else:
		r = m
print(r)


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)

def __starting_point():
	main()
__starting_point()


def is_good(mid, key):
	return sum(((a + mid - 1) // mid for a in A)) - N <= key

def binary_search(bad, good, key):
	while good - bad > 1:
		mid = (bad + good) // 2
		if is_good(mid, key):
			good = mid
		else:
			bad = mid
	return good
(N, K, *A) = list(map(int, open(0).read().split()))
print(binary_search(0, 1000000000, K))


import math
(N, K) = map(int, input().split())
As = list(map(int, input().split()))
r = max(As)
if K == 0:
	print(r)
	exit()
l = 1
while l < r:
	mid = (r + l) // 2
	cnt = 0
	for a in As:
		cnt += math.ceil(a / mid) - 1
	if cnt <= K:
		r = mid
	else:
		l = mid + 1
print(r)


(n, k, *a) = map(int, open(0).read().split())
ok = 10 ** 9
ng = 0
while ok - ng > 1:
	x = ok + ng >> 1
	if -sum((-b // x + 1 for b in a)) > k:
		ng = x
	else:
		ok = x
print(ok)


def f(x):
	now = 0
	for i in range(n):
		now += (a[i] - 1) // x
	return now <= k
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ng = 0
ok = int(1000000000.0)
while ok - ng > 1:
	x = (ok + ng) // 2
	if f(x):
		ok = x
	else:
		ng = x
print(ok)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
ng = 0
ok = max(a) + 1
while ok - ng > 1:
	mid = (ok + ng) // 2
	cur = 0
	for x in a:
		cur += (x - 1) // mid
	if cur > k:
		ng = mid
	else:
		ok = mid
print(ok)


(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
	cnt = 0
	for a in A:
		if a > mid:
			if a % mid == 0:
				cnt += a // mid - 1
			else:
				cnt += a // mid
	if cnt > K:
		l = mid
	else:
		r = mid
print(r)


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)


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

def ok(arg):
	cnt = 0
	for log in a:
		cnt += -(-log // arg)
		cnt -= 1
	return cnt <= k
(st, en) = (0, max(a))
mid = 0
while en - st > 1:
	mid = (en + st) // 2
	if ok(mid):
		en = mid
	else:
		st = mid
print(en)


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

def is_ok(mid):
	x = 0
	for a in A:
		x += -(-a // mid) - 1
	if x <= K:
		return True
	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
print(meguru_bisect(0, max(A)))


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
low = 0
high = max(A)
while high - low > 1:
	mid = (low + high) // 2
	cnt = 0
	for i in A:
		cnt += (i - 1) // mid
	if cnt > K:
		low = mid
	else:
		high = mid
print(high)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
(l, r) = (1, 10 ** 9 + 1)
while r - l > 1:
	t = (l + r) // 2
	k = sum([(a + t - 2) // (t - 1) - 1 for a in A])
	if K < k:
		l = t
	else:
		r = t
print(l)


from sys import stdin
import numpy as np
(n, k) = list(map(int, stdin.readline().split()))
a = np.array(stdin.readline().split(), dtype=np.int64)
ng = 0
ok = 10 ** 9 + 1
while ok - ng > 1:
	mid = ok + ng >> 1
	if np.sum(0 - -a // mid - 1) <= k:
		ok = mid
	else:
		ng = mid
print(ok)


(_, k) = list(map(int, input().split()))
A = [*[int(x) - 1 for x in input().split()]]
(ng, ok) = (0, 1 << 30)
while ok - ng > 1:
	m = (ng + ok) // 2
	if k < sum((a // m for a in A)):
		ng = m
	else:
		ok = m
print(ok)


import sys
import heapq
import math

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

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

	def is_good(mid, key):
		kk = 0
		for a in A:
			kk += -(-a // mid) - 1
		if kk <= key:
			return True
		else:
			return False

	def bi_search(bad, good, key):
		while good - bad > 1:
			mid = (bad + good) // 2
			if is_good(mid, key):
				good = mid
			else:
				bad = mid
		return good
	print(bi_search(0, 1000000000, k))

def __starting_point():
	main()
__starting_point()


(N, K) = list(map(int, input().split()))
log_ls = list(map(int, input().split()))
Max = max(log_ls)

def less_k(min_length, log_ls=log_ls, K=K):
	times = 0
	for log in log_ls:
		if log % min_length == 0:
			times += log // min_length - 1
		else:
			times += log // min_length
	if times <= K:
		return True
	else:
		return False

def return_min_length():
	r = Max
	l = -1
	while True:
		next_length = (r + l) // 2
		if next_length == 0 or not less_k(next_length):
			l = next_length
		else:
			r = next_length
		if r - l == 1:
			return r
ans = return_min_length()
print(ans)


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

def c(x):
	res = 0
	for b in a:
		res += 0 - -b // x - 1
	return res <= k
ng = 0
ok = 10 ** 10
while ok - ng > 1:
	mid = ok + ng >> 1
	if c(mid):
		ok = mid
	else:
		ng = mid
print(ok)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
mi = 0
ma = 10 ** 9
while ma - mi != 1:
	c = 0
	mid = (ma + mi) // 2
	for i in range(N):
		c += A[i] // mid - (A[i] % mid == 0)
	if c > K:
		mi = mid
	else:
		ma = mid
print(ma)


import heapq
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
lef = 0
rig = max(a)
while rig - lef != 1:
	now = -(-(lef + rig) // 2)
	cou = 0
	for i in range(n):
		cou += -(-a[i] // now) - 1
	if cou <= k:
		rig = now
	elif cou > k:
		lef = now
print(rig)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ok = 10 ** 10
ng = 1
for i in range(40):
	chk = (ok + ng) // 2
	cnt = 0
	for j in range(n):
		cnt += (a[j] + chk - 1) // chk - 1
	if cnt > k:
		ng = chk
	else:
		ok = chk
print(ok)


(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)


from math import ceil
(n, k, *aa) = map(int, open(0).read().split())
left = 0
right = max(aa)
while right - left > 1:
	mid = (left + right) // 2
	summ = sum((0 - -a // mid - 1 for a in aa))
	if summ <= k:
		right = mid
	else:
		left = mid
print(right)


import math
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
x0 = 0
x1 = 10 ** 9
while 1:
	sum = 0
	mid = (x0 + x1) // 2
	for i in range(n):
		sum += math.ceil(a[i] / mid) - 1
	if sum <= k:
		x1 = mid
	if sum > k:
		x0 = mid
	if x0 + 1 == x1:
		print(x1)
		break


(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
	s = 0
	for x in a:
		s += (x - 1) // m
	if s <= k:
		r = m
	else:
		l = m
print(r)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
(l, r) = (10 ** 9, 0)
while l - r > 1:
	t = (l + r) // 2
	if sum(((i - 1) // t for i in a)) > k:
		r = t
	else:
		l = t
print(l)


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
	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())
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)


(n, k) = list(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)


I = lambda : list(map(int, input().split()))
(n, k) = I()
l = I()
low = 1
high = max(l)
while low < high:
	mid = (low + high) // 2
	temp = 0
	for i in l:
		temp += i // mid - (i % mid == 0)
	if temp > k:
		low = mid + 1
	else:
		high = mid
print(low)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
left = 0
right = max(a)
while right - left > 1:
	mid = (right + left) // 2
	tmp = 0
	for i in a:
		tmp += (i - 1) // mid
	if tmp <= k:
		right = mid
	else:
		left = mid
print(right)


import math
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ng = 0
ok = 10 ** 9
while ok - ng > 1:
	l = (ng + ok) // 2
	kt = 0
	for i in range(n):
		kt += a[i] // l - (0 if a[i] % l else 1)
	if kt <= k:
		ok = l
	else:
		ng = l
print(ok)


from math import floor
m = 0
M = 10 ** 9 + 1
(N, K) = map(int, input().split())
A = list(map(int, input().split()))

def OK(p):
	if sum([(a - 1) // p 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())
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)


import math
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
left = 1
right = 10 ** 9
while left < right:
	cnt = 0
	mid = (left + right) // 2
	for i in range(n):
		cnt += math.ceil(a[i] / mid) - 1
	if cnt <= k:
		right = mid
	else:
		left = mid + 1
print(left)


def waru(a, b):
	if a % b == 0:
		return a // b
	else:
		return a // b + 1
(N, K) = map(int, input().split())
A = list(map(int, input().split()))
ue = sum(A)
sita = 1
for i in range(50):
	n = (ue + sita) // 2
	L = [waru(i, n) - 1 for i in A]
	if sum(L) > K:
		sita = n
	else:
		ue = n
	if ue == sita:
		print(ue)
		return
	elif ue - sita == 1:
		n = sita
		L = [waru(i, n) - 1 for i in A]
		if sum(L) > K:
			print(n + 1)
			return
		else:
			print(n)
			return


import math
(N, K) = map(int, input().split())
A = list(map(int, input().split()))
low = 0
high = max(A)
while low <= high:
	if high == low:
		break
	mid = (low + high) // 2
	if mid == 0:
		break
	sum = 0
	for i in range(N):
		sum += math.ceil(A[i] / mid) - 1
	if sum > K:
		low = mid + 1
	else:
		high = mid
print(high)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
(l, r) = (0, max(a))

def ok(m):
	cut = 0
	for x in a:
		cut += (x - 1) // m
	return cut <= k
while r - l > 1:
	m = (l + r) // 2
	if ok(m):
		r = m
	else:
		l = m
print(r)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
l = 1
r = 10 ** 9 + 1
while l < r:
	mid = (l + r) // 2
	counter = 0
	for i in range(N):
		if A[i] > mid:
			counter += A[i] // mid
	if counter <= K:
		r = mid
	else:
		l = mid + 1
print(l)


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()


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
ok = max(l)
ng = 0

def solve(m):
	s = 0
	for i in l:
		s += -(-i // m) - 1
	return s
while ok - ng > 1:
	m = (ok + ng) // 2
	if k < solve(m):
		ng = m
	else:
		ok = m
print(ok)


f = lambda : [*map(int, input().split())]
(n, k) = f()
a = f()
a = [i * 100 for i in a]

def ok(x):
	c = 0
	for i in a:
		c += 0 - -i // x
	return c <= n + k
(l, r) = (0, 10 ** 11 + 1)
while r - l > 1:
	m = l + r >> 1
	if ok(m):
		r = m
	else:
		l = m
t = 0 - -r // 100
print(t - ok(t - 1) if t > 1 else t)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
s = 0
t = max(A)
while s + 1 < t:
	m = (s + t) // 2
	temp = 0
	for i in A:
		temp += (i - 1) // m
	if temp <= K:
		t = m
	else:
		s = m
print(t)


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

def f(L):
	res = 0
	for x in A:
		res += (x - 1) // L
	return res
l = 0
r = max(A)
while r - l > 1:
	M = (r + l) // 2
	if f(M) > K:
		l = M
	else:
		r = M
print(r)


(n, k) = map(int, input().split())
A = [*map(int, input().split())]
A.sort(reverse=True)
(ng, ok) = (0, 1 << 30)
while ok - ng > 1:
	m = (ng + ok) // 2
	c = 0
	for a in A:
		d = (a - 1) // m
		if d == 0:
			break
		c += d
	if c <= k:
		ok = m
	else:
		ng = m
print(ok)


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
ng = 0
ok = max(A)
while abs(ok - ng) > 1:
	mid = (ok + ng) // 2
	now = 0
	for i in A:
		now += i // mid - 1 if i % mid == 0 else i // mid
	if now > k:
		ng = mid
	else:
		ok = mid
print(ok)


def meg_bisect(ng, ok, func):
	while abs(ok - ng) > 1:
		mid = (ok + ng) // 2
		if func(mid):
			ok = mid
		else:
			ng = mid
	return ok
(n, k, *a) = map(int, open(0).read().split())
print(meg_bisect(0, max(a), lambda x: sum((0 - -b // x - 1 for b in a)) <= k))


def check(lis, k, mid):
	for i in lis:
		if i % mid == 0:
			k += 1
		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)


(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)


(n, k) = map(int, input().split())
A = [*map(int, input().split())]
(ng, ok) = (0, 1 << 32)
while ok - ng > 1:
	m = (ng + ok) // 2
	c = 0
	for a in A:
		c += (a - 1) // m
	if c <= k:
		ok = m
	else:
		ng = m
print(ok)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = 0
r = 10 ** 9 + 1
ref = 0
while r - l > 1:
	now = (l + r) // 2
	for i in a:
		ref += 0 - -i // now - 1
	if ref <= k:
		ref = 0
		r = now
	else:
		ref = 0
		l = now
print(r)


from math import ceil

def check(x):
	cnt = 0
	for a in A:
		cnt += ceil(a / x) - 1
	return cnt <= K
(N, K) = list(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)


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)


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

def check(x):
	c = 0
	for i in range(n):
		c += a[i] // x
		if a[i] % x == 0:
			c -= 1
	if c <= k:
		return True
	else:
		return False
mx = max(a)
mn = 0
ans = [mx]
while mn <= mx:
	m = (mx + mn) // 2
	if m == 0:
		if check(1):
			ans.append(1)
		break
	if check(m):
		mx = m - 1
		ans.append(m)
	else:
		mn = m + 1
print(min(ans))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
l = 0
r = a[-1]
while r - l > 1:
	cnt = 0
	m = (l + r) // 2
	for i in a:
		cnt += (i - 1) // m
	if cnt <= k:
		r = m
	else:
		l = m
print(r)


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

def is_ok(arg):
	cnt = 0
	for i in alist:
		cnt += (i - 1) // arg
	return cnt <= k

def nibun(ng, ok):
	while abs(ok - ng) > 1:
		mid = (ok + ng) // 2
		if is_ok(mid):
			ok = mid
		else:
			ng = mid
	return ok
print(nibun(0, 10 ** 9 + 1))


from math import ceil
(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
ng = 0
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 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))

def __starting_point():
	main()
__starting_point()


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
l = 1
r = 10 ** 9 + 1
while l < r:
	mid = (l + r) // 2
	count = 0
	for i in range(n):
		if A[i] > mid:
			count += A[i] // mid
	if count <= k:
		r = mid
	else:
		l = mid + 1
print(l)


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

def is_ok(l):
	cnt = 0
	for L in a:
		cnt += -(-L // l) - 1
	return cnt <= k

def bisect(top, bot):
	while top - bot > 1:
		mid = (top + bot) // 2
		if is_ok(mid):
			top = mid
		else:
			bot = mid
	return top
print(bisect(max(a), 0))


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

def flag(mid):
	count = 0
	for a0 in a:
		count += math.ceil(a0 / mid) - 1
	if count <= k:
		return True
	else:
		return False

def cal(i, j):
	while abs(i - j) > 1:
		mid = (i + j) // 2
		if flag(mid):
			j = mid
		else:
			i = mid
	print(j)
cal(0, max(a))


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

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


(N, K) = map(int, input().split())
As = sorted(map(int, input().split()))
ng = 0
ok = 1001001001
while ok - ng > 1:
	mid = (ng + ok) // 2
	count = 0
	for A in As:
		count += -(-A // mid)
		count -= 1
	if count <= K:
		ok = mid
	else:
		ng = mid
print(ok)


import sys
(n, k, *aaa) = map(int, sys.stdin.buffer.read().split())
l = 0
r = max(aaa)
while l + 1 < r:
	m = (l + r) // 2
	cut = 0
	for a in aaa:
		cut += (a - 1) // m
	if cut > k:
		l = m
	else:
		r = m
print(r)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
a = 0
b = 10 ** 9 + 1
while a + 1 < b:
	mid = (a + b) // 2
	ans = 0
	for i in A:
		ans += (i - 1) // mid
	if K < ans:
		a = mid
	else:
		b = mid
print(b)


import math
(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
(l, r) = (0, 10 ** 9 + 2)
while r - l > 1:
	key = (r + l) // 2
	count = 0
	for i in range(n):
		count += (a[i] - 1) // key
	if count <= k:
		r = key
	else:
		l = key
print(r)


from math import ceil
(N, K) = list(map(int, input().split()))
A = list(map(int, input().split()))

def f(x):
	cnt = 0
	for a in A:
		cnt += ceil(a / x) - 1
	return True if cnt <= K else False
(OK, NG) = (10 ** 9, 0)
while OK - NG > 1:
	mid = (OK + NG) // 2
	if f(mid):
		OK = mid
	else:
		NG = mid
print(OK)


from bisect import bisect
import math
(n, k) = map(int, input().split())
A = list(map(int, input().split()))
(l, r) = (0, max(A))
while l < r - 1:
	mid = (l + r) // 2
	cnt = 0
	for a in A:
		cnt += math.ceil(a / mid) - 1
	if cnt <= k:
		r = mid
	else:
		l = mid
print(r)


(_, k) = map(int, input().split())
A = [*map(int, input().split())]
(ng, ok) = (0, 1 << 30)
while ok - ng > 1:
	m = (ng + ok) // 2
	if k < sum(map(lambda a: (a - 1) // m, A)):
		ng = m
	else:
		ok = m
print(ok)


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)))
	return

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]))


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


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 = 0
hi = max(a) + 1
while hi - lo > 1:
	mid = (lo + hi) // 2
	if check(a, mid) <= k:
		hi = mid
	else:
		lo = mid
print(hi)


import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
from functools import lru_cache
import copy
input = sys.stdin.readline
INF = float('inf')
mod = 10 ** 9 + 7
eps = 10 ** (-7)

def inp():
	return int(input())

def inpl():
	return list(map(int, input().split()))

def str_inp():
	return list(input()[:-1])
(n, k) = inpl()
a = inpl()
l = 0
r = 10 ** 9
while l + 1 < r:
	x = (l + r) // 2
	cnt = 0
	for i in range(n):
		cnt += math.ceil(a[i] / x) - 1
		if cnt > k:
			break
	if cnt <= k:
		r = x
	else:
		l = x
print(r)


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

	def value(v):
		cnt = 0
		for i in a:
			cnt += (i - 1) // v
		if cnt > k:
			return False
		else:
			return True

	def b_search(ok, ng, value):
		while abs(ok - ng) > 1:
			mid = (ok + ng) // 2
			if value(mid):
				ok = mid
			else:
				ng = mid
		return ok
	print(b_search(10 ** 16, 0, value))
main()


def solve(*args: str) -> str:
	(n, k) = list(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))

def __starting_point():
	print(solve(*open(0).read().splitlines()))
__starting_point()


import math
(N, K) = (int(a) for a in input().split())
A = [int(a) for a in input().split()]

def isOK(X):
	cutcount = 0
	for i in range(N):
		cutcount += math.ceil(A[i] / X) - 1
	if cutcount <= K:
		return True
	else:
		return False

def binary_search():
	left = 0
	right = max(A) + 1
	while right - left > 1:
		mid = left + (right - left) // 2
		if isOK(mid):
			right = mid
		else:
			left = mid
	return right
print(binary_search())


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
L = 0
R = 10 ** 9
while R - L > 1:
	M = L + R >> 1
	C = 0
	for i in A:
		C += (i - 1) // M
	if C <= K:
		R = M
	else:
		L = M
print(R)


(n, k, *a) = map(int, open(0).read().split())
(l, r) = (0, 10 ** 9)
while r - l > 1:
	m = l + r >> 1
	if sum((0 - -i // m for i in a)) > n + k:
		l = m
	else:
		r = m
print(r)


(N, K) = map(int, input().split())
l = list(map(int, input().split()))
import math

def f(n):
	A = 0
	for i in l:
		A += math.ceil(i / n) - 1
	return A <= K

def bis(ng, ok):
	while abs(ok - ng) > 1:
		mid = (ok + ng) // 2
		if f(mid):
			ok = mid
		else:
			ng = mid
	return ok
print(bis(0, max(l)))


(N, K) = map(int, input().split())
Alist = list(map(int, input().split()))
left = 0
right = max(Alist)
while right - left > 1:
	mid = (left + right) // 2
	cnt = 0
	for A in Alist:
		if A % mid == 0:
			cnt += A // mid - 1
		else:
			cnt += A // mid
	if cnt <= K:
		right = mid
	else:
		left = mid
print(right)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
l = 1
r = max(A)
while l != r:
	mid = (r + l) // 2
	count = 0
	for log in A:
		count += (log - 1) // mid
	if count <= K:
		r = mid
	else:
		l = mid + 1
print(r)


import math
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
(l, r) = (0, max(a))
while 1 < r - l:
	m = (l + r) // 2
	c = 0
	for i in a:
		c += math.ceil(i / m) - 1
	if c > k:
		l = m
	else:
		r = m
print(r)


(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)


import math
(n, k) = map(int, input().split())
a = tuple(map(int, input().split()))
l = 0
r = max(a)
count = 0
while count < 100:
	m = (l + r) / 2
	kk = 0
	for ai in a:
		kk += math.ceil(ai / m - 1)
	if kk <= k:
		r = m
	else:
		l = m
	count += 1
print(math.ceil(l))


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

def cnt(x):
	ret = 0
	for ai in a:
		ret += (ai + (x - 1)) // x - 1
	return ret
(ok, ng) = (a[-1], 0)
while ok - ng > 1:
	nw = (ok + ng) // 2
	if cnt(nw) <= k:
		ok = nw
	else:
		ng = nw
print(ok)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
MIN = 0
MAX = 10 ** 9
while MAX - MIN > 1:
	mid = (MAX + MIN) // 2
	tmp = 0
	for i in range(N):
		tmp += (A[i] - 1) // mid
	if tmp > K:
		MIN = mid
	else:
		MAX = mid
print(MAX)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
ans = []
c = 2 ** 30
r = 2 ** 30
while r:
	r //= 2
	l = sum((-(-a // c) - 1 for a in A))
	if l > K:
		c += r
	else:
		ans.append(c)
		c -= r
print(ans and min(ans) or 1)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
hi = 10 ** 18
lo = 0
while hi - lo > 1:
	mid = (hi + lo) // 2
	cut = 0
	for i in range(N):
		cut += (A[i] + mid - 1) // mid - 1
	if cut <= K:
		hi = mid
	else:
		lo = mid
print(hi)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
(leq, high) = (0, 10000000000.0)
while high - leq > 1:
	l = int((leq + high) / 2)
	cnt = 0
	for ai in a:
		cnt += int((ai - 1) / l)
	if cnt > k:
		leq = l
	else:
		high = l
print(high)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ng = 0
ok = 10 ** 9 + 1

def check(x):
	cnt = 0
	for l in a:
		cnt += (l - 1) // x
	return cnt <= k
while abs(ok - ng) > 1:
	m = (ok + ng) // 2
	if check(m):
		ok = m
	else:
		ng = m
print(ok)


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

def check(l):
	count = 0
	for L in A:
		count += L // l
		if L % l != 0:
			count += 1
		count -= 1
	return count <= K
(bottom, top) = (0, max(A))
while top - bottom > 1:
	mid = (top + bottom) // 2
	if check(mid):
		top = mid
	else:
		bottom = mid
print(top)


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

def is_ok(l):
	cnt = 0
	for i in range(n):
		cnt += ceil(a[i] / l) - 1
	return True if cnt <= k else 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
print(meguru_bisect(0, a[-1] + 1))


import math
from heapq import heappop
import heapq
(N, K) = map(int, input().split())
A = list(map(int, input().split()))
l = 0
r = max(A) + 1
while l + 1 < r:
	m = (l + r) // 2
	tmp = 0
	for a in A:
		tmp += math.ceil(a / m) - 1
	if tmp <= K:
		r = m
	else:
		l = m
print(r)


(n, k, *A) = map(int, open(0).read().split())
l = 1
r = max(A)
while l != r:
	c = (l + r) // 2
	if k >= sum((-(-a // c) - 1 for a in A)):
		r = c
	else:
		l = c + 1
print(l)


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

def num_of_chopping(l, threshold):
	cnt = 0
	for i in l:
		cnt += -(-i // threshold) - 1
	return cnt
low = 0
high = max(A)
while low + 1 < high:
	mid = (low + high) // 2
	cnt = num_of_chopping(A, mid)
	if cnt <= K:
		high = mid
	else:
		low = mid
print(high)


(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))


from math import ceil
(N, K) = map(int, input().split())
A = [*map(int, input().split())]
(l_lb, l_min) = (0, max(A))
while l_min - l_lb > 1:
	l_mid = (l_lb + l_min) // 2
	if sum((ceil(a / l_mid) for a in A)) - N > K:
		l_lb = l_mid
	else:
		l_min = l_mid
print(l_min)


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

def cnt(x):
	s = 0
	for i in ar:
		if i > x:
			s += (i - 1) // x
	return s
l = 0
r = 10 ** 9
while l < r - 1:
	m = (l + r) // 2
	c = cnt(m)
	if c > k:
		l = m
	else:
		r = m
print(r)


(n, k) = map(int, input().split())
(*a,) = map(int, input().split())
(l, r) = (0, 10 ** 9)
while r - l > 1:
	m = (l + r) // 2
	t = 0
	for x in a:
		if x <= m:
			continue
		t += (x + m - 1) // m - 1
	if t <= k:
		r = m
	else:
		l = m
print(r)


(N, K) = map(int, input().split())
L = list(map(int, input().split()))
import math
MAX = 10 ** 9
MIN = 0
for i in range(100):
	Mid = (MAX + MIN) / 2
	cnt = 0
	for j in range(N):
		cnt += L[j] // Mid
	if cnt <= K:
		MAX = Mid
	else:
		MIN = Mid
print(math.ceil(Mid))


import sys
from itertools import chain

def cut_count(A, 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)

def __starting_point():
	main()
__starting_point()


(N, K, *A) = map(int, open(0).read().split())

def is_ok(x):
	cnt = 0
	for a in A:
		cnt += -(-a // x) - 1
	return cnt <= K
(ng, ok) = (0, 10 ** 10)
while abs(ok - ng) > 1:
	mid = (ok + ng) // 2
	if is_ok(mid):
		ok = mid
	else:
		ng = mid
print(ok)


(n, k) = map(int, input().split())
(*A,) = map(int, input().split())
(a, b) = (0, 10 ** 9)
while b - a > 1:
	x = (a + b) // 2
	cut = 0
	for i in range(n):
		cut += -(-A[i] // x) - 1
	if cut <= k:
		b = x
	else:
		a = x
print(b)


(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(r)


(N, K) = list(map(int, input().split()))
A = list(map(int, input().split()))
NG = 0
OK = max(A) + 1
while OK - NG > 1:
	mid = (OK + NG) // 2
	cur = 0
	for x in A:
		cur += (x - 1) // mid
	if cur > K:
		NG = mid
	else:
		OK = mid
print(OK)


(n, k) = list(map(int, input().split()))
m = list(map(int, input().split()))
import math

def pos(h):
	p = 0
	for i in range(n):
		p += math.ceil(m[i] / h) - 1
	return bool(p <= k)
(l, r) = (1, max(m))
while l < r:
	mid = (l + r) // 2
	if pos(mid):
		r = mid
	else:
		l = mid + 1
print(l)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ok = max(a)
ng = 0
while ok - ng > 1:
	mid = (ok + ng) // 2
	cnt = 0
	for i in range(n):
		num = a[i]
		cnt += -(-num // mid) - 1
	if cnt <= k:
		ok = mid
	else:
		ng = mid
print(ok)


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

def cond(x):
	s = 0
	for i in range(n):
		s += math.ceil(a[i] / x) - 1
	return s <= k
(l, r) = (0, 10 ** 9)
while l + 1 < r:
	mid = (l + r) // 2
	if cond(mid):
		r = mid
	else:
		l = mid
print(r)


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
ng = 0
ok = max(A)
while abs(ok - ng) > 1:
	mid = (ok + ng) // 2
	cnt = 0
	for a in A:
		cnt += (a - 1) // mid
	if cnt <= k:
		ok = mid
	else:
		ng = mid
print(ok)


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]
c = k - sum((int(a / t) - 1 for a in A))
X = []
for a in A:
	X.append(ceil(a / ceil(a / t)))
	X.append(ceil(a / int(a / t)))
X.sort()
print(X[-c - 1])


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
if k >= sum(a) - n:
	print(1)
else:
	(ok, ng) = (10 ** 9, 1)
	while ok - ng > 1:
		mid = (ok + ng) // 2
		if sum(((x - 1) // mid for x in a)) <= k:
			ok = mid
		else:
			ng = mid
	print(ok)


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


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ll = 0
rr = 10 ** 9 + 1
for _ in range(10 ** 2):
	ans = (ll + rr) / 2.0
	cnt = 0
	for item in a:
		if item > ans:
			cnt += -1 * item // ans * -1 - 1
	if cnt <= k:
		rr = ans
	else:
		ll = ans
print(int(-1 * ans // 1 * -1))


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = 1
r = 10 ** 9
import math
for i in range(100):
	temp = 0
	m = (r + l) / 2
	for j in a:
		temp += j // m
	if temp <= k:
		r = m
	else:
		l = m
print(math.ceil(m))


(N, K) = list(map(int, input().split()))
(*A,) = list(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)


(N, K) = list(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)


import math
(N, K) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
l = 0
r = a[-1] + 1
while r - l > 1:
	mid = (r + l) // 2
	cnt = 0
	for i in a:
		cnt += (i - 1) // mid
	if cnt <= K:
		r = mid
	else:
		l = mid
print(r)


import math
(N, K) = map(int, input().split())
A = list(map(int, input().split()))
left = 0
right = max(A) + 1
while left + 1 != right:
	mid = (left + right) // 2
	x = 0
	for a in A:
		x += math.ceil(a / mid) - 1
	if x <= K:
		right = mid
	else:
		left = mid
print(right)


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

def func(l, r):
	if l == r:
		return l
	mid = (l + r) // 2
	count = 0
	for i in A:
		count += (i - 0.1) // mid
	if count <= K:
		return func(l, mid)
	else:
		return func(mid + 1, r)
print(func(1, max(A)))


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

def solve(x):
	kk = k
	for i in a:
		kk -= (i + x - 1) // x - 1
	return kk >= 0
ok = 10 ** 9
ng = 0
while abs(ok - ng) > 1:
	mid = (ok + ng) // 2
	if solve(mid):
		ok = mid
	else:
		ng = mid
print(ok)


(n, k) = list(map(int, input().split()))
alst = list(map(int, input().split()))
ok = max(alst)
ng = 0
while abs(ok - ng) > 1:
	cen = (ok + ng) // 2
	cnt = 0
	for a in alst:
		cnt += (a + cen - 1) // cen - 1
	if cnt <= k:
		ok = cen
	else:
		ng = cen
print(ok)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ng = 0
ok = max(a)
while ng + 1 != ok:
	mid = (ng + ok) // 2
	ans = 0
	for aa in a:
		if aa % mid == 0:
			ans += aa // mid - 1
		else:
			ans += aa // mid
	if ans <= k:
		ok = mid
	else:
		ng = mid
print(ok)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
l = 0
r = 2 * 10 ** 9 + 10 ** 6
while r - l > 1:
	m = (r + l) // 2
	cnt = 0
	for a in A:
		cnt += (a + m - 1) // m
	if cnt <= N + K:
		r = m
	else:
		l = m
print(r)


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(n, k) = I()
l = I()
lo = 1
hi = max(l)
while lo < hi:
	md = (lo + hi) // 2
	ct = 0
	for i in range(n):
		ct += l[i] // md - (l[i] % md == 0)
	if ct <= k:
		hi = md
	else:
		lo = md + 1
print(lo)


import math
(N, K) = map(int, input().split())
A = list(map(int, input().split()))
l = 0
r = int(1000000000.0)

def f(x):
	count = 0
	for a in A:
		count += int((a - 1) / x)
	return count <= K
while r - l > 1:
	x = int((r + l) / 2)
	if f(x):
		r = x
	else:
		l = x
print(r)


(n, k) = map(int, input().split())
a = tuple(map(int, input().split()))
ok = 10 ** 9
ng = 0
while abs(ng - ok) > 1:
	mid = (ok + ng) // 2
	cnt = 0
	for i in a:
		cnt += (i + mid - 1) // mid - 1
	if cnt <= k:
		ok = mid
	else:
		ng = mid
print(ok)


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

def isOk(x):
	cnt = 0
	for a in A:
		cnt += (a - 1) // 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
print(ok)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
inf = 1
sup = max(a)
while inf < sup:
	x = (inf + sup) // 2
	cut = 0
	for a_i in a:
		cut += (a_i - 1) // x
	if cut <= k:
		sup = x
	else:
		inf = x + 1
print(sup)


(N, K) = map(int, input().split())
A = [int(a) for a in input().split()]

def chk(x):
	s = 0
	for a in A:
		s += (a - 1) // x
	return 1 if s <= K else 0
(l, r) = (0, 1 << 30)
while r - l > 1:
	m = (l + r) // 2
	if chk(m):
		r = m
	else:
		l = m
print(r)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = 0
r = 10 ** 9

def check(x):
	now = 0
	for i in range(n):
		now += (a[i] - 1) // x
	return now <= k
while r - l > 1:
	x = (l + r) // 2
	if check(x):
		r = x
	else:
		l = x
print(r)


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

def binsearch(minz, maxz):
	if minz >= maxz:
		return minz
	mid = (maxz + minz) // 2
	ncut = 0
	for i in range(N):
		thiscut = int((logs[i] + mid - 1) / mid) - 1
		ncut += thiscut
		if ncut > K:
			return binsearch(mid + 1, maxz)
	if ncut < K:
		return binsearch(minz, mid)
	maxx = 0
	for i in range(N):
		thiscut = int((logs[i] + mid - 1) / mid) - 1
		thislen = int((logs[i] + thiscut) / (thiscut + 1))
		if maxx < thislen:
			maxx = thislen
	return maxx
if K > 0:
	ans = binsearch(1, maxL + 1)
else:
	ans = maxL
print(ans)


(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
	b = list(map(lambda x: -(-x // m) - 1, a))
	ans = sum(b)
	if ans <= k:
		r = m
	else:
		l = m
print(r)


(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)


import sys
readline = sys.stdin.readline
(N, K) = map(int, readline().split())
A = list(map(int, readline().split()))
l = 0
r = 10 ** 10

def test(m):
	return sum(((a + m - 1) // m for a in A)) - N <= K
while l + 1 < r:
	m = (l + r) // 2
	if test(m):
		r = m
	else:
		l = m
print(r)


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

def check(x):
	count = 0
	for Ai in A:
		count += (Ai - 1) // x
	return count <= K
ok = 10 ** 9
ng = 0
while ok - ng > 1:
	mid = (ok + ng) // 2
	if check(mid):
		ok = mid
	else:
		ng = mid
print(ok)


import sys
input = sys.stdin.readline
(N, K) = map(int, input().split())
A = list(map(int, input().split()))
OK = 10 ** 9
NG = 0
while OK - NG > 1:
	mid = (OK + NG) // 2
	ANS = 0
	for a in A:
		ANS += (a - 0.01) // mid
	if ANS <= K:
		OK = mid
	else:
		NG = mid
print(OK)


(n, k) = map(int, input().split())
list_A = list(map(int, input().split()))
(l, r) = (0, max(list_A))
while l + 1 < r:
	(m, cnt) = ((r + l) // 2, 0)
	for a in list_A:
		cnt += (a - 1) // m
	if cnt > k:
		l = m
	else:
		r = m
print(r)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
(x0, x1) = (0, 10 ** 9)
while x0 + 1 < x1:
	x = (x0 + x1) // 2
	s = sum(((a - 1) // x for a in A))
	if s > K:
		x0 = x
	else:
		x1 = x
print(x1)


from math import ceil
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = 0
r = max(a)

def f(ln, x):
	return ceil(ln / x) - 1
while r - l > 1:
	m = (r + l) // 2
	cnt = 0
	for i in range(n):
		cnt += f(a[i], m)
	if cnt > k:
		l = m
	else:
		r = m
print(r)


(N, K) = map(int, input().split())
AList = list(map(int, input().split()))
l = 0
r = 10 ** 9
while r - l > 1:
	x = (l + r) // 2
	now = 0
	for a in AList:
		now += (a - 1) // x
	f = lambda now: True if now <= K else False
	if f(now):
		r = x
	else:
		l = x
print(r)


(N, K) = map(int, input().split())
A = sorted(list(map(int, input().split())))
(L, R) = (0, A[-1])
while R - L > 1:
	mid = L + (R - L) // 2
	if sum([(a - 1) // mid for a in A]) <= K:
		R = mid
	else:
		L = mid
print(R)


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

def f(x):
	r = 0
	for a in A:
		r += (a + x - 1) // x - 1
	return r
a = 0
b = 2 ** 32
while b > 0:
	if f(a + b) > K:
		a += b
	b //= 2
print(a + 1)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ng = 0
ok = 10 ** 9
while ng < ok - 1:
	mid = (ng + ok) // 2
	count = sum(((ai - 1) // mid for ai in a))
	if count <= k:
		ok = mid
	else:
		ng = mid
print(ok)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
(l, r) = (1, max(A))
while l < r:
	m = (l + r) // 2
	s = sum([a // m + (not a % m == 0) - 1 for a in A])
	if s <= K:
		r = m
	else:
		l = m + 1
print(r)


ceil = lambda a, b: (a + b - 1) // b
(N, K) = map(int, input().split())
A = tuple(map(int, input().split()))
(l, r) = (0, max(A))
while r - l > 1:
	m = (l + r) // 2
	if sum((ceil(x, m) - 1 for x in A)) > K:
		l = m
	else:
		r = m
print(r)


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

def check(length):
	cuttings = sum(((l + length - 1) // length - 1 for l in a))
	return cuttings <= k
(l, r) = (0, max(a))
while l + 1 < r:
	mid = (l + r) // 2
	if check(mid):
		r = mid
	else:
		l = mid
print(r)


def is_ok(x):
	cnt = 0
	for a in A:
		cnt += -(-a // x) - 1
	if cnt <= k:
		return True
	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) = list(map(int, input().split()))
A = list(map(int, input().split()))
print(meguru_bisect(0, 10 ** 9 + 1))


(n, k) = map(int, input().split())
A = [int(x) for x in input().split()]
(s, l) = (0, max(A))
while l - s > 1:
	m = (s + l) // 2
	if sum([(a - 1) // m for a in A]) > k:
		s = m
	else:
		l = m
print(l)


(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)


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)


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

def check(n):
	cnt = 0
	for a in A:
		cnt += (a - 1) // n
	return cnt <= K
ng = 0
ok = 10 ** 9
while abs(ng - ok) > 1:
	i = (ng + ok) // 2
	if check(i):
		ok = i
	else:
		ng = i
print(ok)


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

def is_ok(x):
	c = 0
	for i in a:
		c += ceil(i / x) - 1
		if c > k:
			return False
	return True

def binary_search(m):
	left = 0
	right = m + 1
	while left <= right:
		center = (left + right) // 2
		if right - left == 1:
			return right
		elif is_ok(center):
			right = center
		else:
			left = center
if k == 0:
	print(max(a))
else:
	print(binary_search(max(a)))


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
ng = 0
ok = 10 ** 10
while ok - ng > 1:
	mid = (ok + ng) // 2
	c = 0
	for i in range(n):
		c = c + (A[i] + mid - 1) // mid
	if c > k + n:
		ng = mid
	else:
		ok = mid
print(ok)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
hi = 10 ** 9
lo = 0
while hi - lo > 1:
	mid = (hi + lo) // 2
	cnt = 0
	for v in a:
		cnt += (v + mid - 1) // mid - 1
	if cnt <= k:
		hi = mid
	else:
		lo = mid
print(hi)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
low = 0
high = max(a)
while low + 1 < high:
	mid = (low + high) // 2
	m = 0
	for x in a:
		m += (x - 1) // mid
	if m <= k:
		high = mid
	else:
		low = mid
print(high)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
import math
l = 0
r = max(a) + 1
for _ in range(100):
	m = (l + r) / 2
	kn = 0
	for i in a:
		kn += i // m
	if kn > k:
		l = m
	else:
		r = m
print(math.ceil(l))


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
OK = 10 ** 9
NG = 0
while OK - NG > 1:
	ans = 0
	mid = (OK + NG) // 2
	for a in A:
		ans += (a - 0.1) // mid
	if ans > K:
		NG = mid
	else:
		OK = mid
print(OK)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
ng = 0
ok = max(A)
while ok - ng > 1:
	cnt = 0
	l = (ok + ng) // 2
	for a in A:
		cnt += a // l + (a % l != 0) - 1
	if cnt <= K:
		ok = l
	else:
		ng = l
print(ok)


(N, K) = map(int, input().split())
A = [int(x) for x in input().split()]
l = 0
r = max(A) + 1
while l + 1 < r:
	m = (l + r) // 2
	count = 0
	for a in A:
		count += (a - 1) // m
	if count > K:
		l = m
	else:
		r = m
print(r)


import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp
INF = inf
MOD = 1000000007
(n, k) = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
tmp = 0
res = inf
low = 0
high = max(A)
while low <= high:
	mid = (low + high) // 2
	tmp = 0
	for i in range(n):
		if mid > 0:
			tmp += ceil(A[i] / mid) - 1
		else:
			tmp = inf
	if tmp <= k:
		res = min(res, mid)
		high = mid - 1
	else:
		low = mid + 1
print(res)


(n, k) = map(int, input().split())
(*A,) = map(int, input().split())
(l, r) = (0, 10 ** 9)
while r - l > 1:
	c = (l + r) // 2
	if sum((-(-a // c) - 1 for a in A)) <= k:
		r = c
	else:
		l = c
print(r)


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

def func(b):
	c = k
	for i in a:
		c -= (i - 1) // b
		if c < 0:
			return False
	return True
l = 1
r = max(a)
while r > l:
	lr = (l + r) // 2
	if func(lr):
		r = lr
	else:
		l = lr + 1
print(r)


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

def check(x):
	k = 0
	for a in A:
		k += (a - 1) // x
	return k <= K
(ng, ok) = (0, 10 ** 9 + 1)
while ok - ng > 1:
	x = (ok + ng) // 2
	if check(x):
		ok = x
	else:
		ng = x
print(ok)


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

def cut(x):
	t = 0
	for i in a:
		if i <= x:
			continue
		t += ceil(i / x) - 1
	return t <= k
(l, r) = (0, 10 ** 9)
while l + 1 < r:
	x = l + (r - l) // 2
	if cut(x):
		r = x
	else:
		l = x
print(r)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
now = 0
scale = 2 ** 32
while scale:
	cnt = 0
	tmp = now + scale
	for x in a:
		cnt += (x - 1) // tmp
	if cnt > k:
		now = tmp
	scale //= 2
print(now + 1)


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)


import math
(N, K) = map(int, input().split())
A = list(map(int, input().split()))
m = 1
M = max(A)
while M - m > 0:
	mm = 0
	mid = (M + m) // 2
	for i in range(N):
		mm += math.ceil(A[i] / mid) - 1
	if mm > K:
		m = mid + 1
	else:
		M = mid
print(math.ceil(m))


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
l = 0
r = max(A) + 1
while r - l > 1:
	m = (l + r) // 2
	cut = 0
	for i in range(n):
		cut += (A[i] + m - 1) // m - 1
	if cut > k:
		l = m
	else:
		r = m
print(r)


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)