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 collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n, k = LI()
    q = []
    a = LI()
    l = 0
    r = max(a)+1
    while l+1 < r:
        m = (l+r) >> 1
        s = sum([math.ceil(i/m) for i in a])-n
        if s <= k:
            r = m
        else:
            l = m
    print(r)
    return


if __name__ == "__main__":
    solve()

Solution (Python):
import math
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7



N, K = list(map(int, sys.stdin.buffer.readline().split()))
A = list(map(int, sys.stdin.buffer.readline().split()))
A = np.array(A, dtype=float)


def test(l):
    
    return np.ceil(A / l - 1).sum() <= K


ok = A.max() + 1
ng = 1e-9
while abs(ok - ng) > 1e-2:
    mid = (ok + ng) / 2
    if test(mid):
        ok = mid
    else:
        ng = mid
ans = math.ceil(ng)
print(ans)

Solution (Python):
def countcut(A, length):
    ret = 0
    for a in A:
        ret += -(-a//length) - 1
    return ret


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    lo = 1
    hi = int(1e9)
    while lo < hi:
        mid = (lo+hi) // 2
        if countcut(A, mid) <= K:
            hi = mid
        else:
            lo = mid + 1
    print(lo)


if __name__ == "__main__":
    main()

Solution (Python):
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)

Solution (Python):
def main():
    N, K = map( int, input().split())
    A = list( map( int, input().split()))
    cnt = 0
    l = 0
    r = 10**9+1
        
    ans = 0
    while r-l > 1:
        m = (l+r)//2
        k = 0
        
        for a in A:
            k += ((a+m-1)//m)-1
        if k <= K:
            r = m
        else:
            l = m
    print(r)
if __name__ == '__main__':
    main()

Solution (Python):
from heapq import *
N,K=map(int,input().split())
A=list(map(int,input().split()))
Q=[]
heapify(Q)
for i in range(N):
  heappush(Q,(-A[i],1))
x=0
if K==0:
  print(max(A))
  exit()
L,R,M=1,max(A),0
while R!=L:
  M=(L+R)//2
  x=0
  for i in range(N):
    x+=(A[i]-1)//M
  if x>K:
    L=max(L+1,M)
  else:
    R=M
print(L)

Solution (Python):
import math,sys
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=0
r=10**9+2
while math.ceil(l)<math.floor(r):
  tr=(l+r)/2
  temp=0
  for i in range(n):
    temp+=math.ceil(a[i]/tr)-1
  if temp<=k:
    r=tr
  else:
    l=tr
tr=math.ceil(l)
if tr==0:
  print(1)
  sys.exit()
temp=0
for i in range(n):
  temp+=a[i]//tr
  if a[i]%tr==0:
    temp-=1
if temp<=k:
  print(tr)
else:
  print(tr+1)

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

Solution (Python):
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)

Solution (Python):

def bisect(ng, ok, judge, eps=1):
    while abs(ng-ok) > eps:
        m = (ng+ok)//2
        if judge(m):
            ok = m
        else:
            ng = m
    return ok

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

K += N
def judge(d):
    return sum((a-1)//d+1 for a in A) <= K


for d in range(1,7):
    r = sum((a-1)//d+1 for a in A)

res = bisect(0,max(A),judge)
print(res)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
'''
自宅用PCでの解答
'''
import math

import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit


ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n,k = map(int,ipt().split())
    a = [int(i) for i in ipt().split()]
    l = 1
    r = 10**9+1
    while l != r:
        mid = l+(r-l)//2
        nm = 0
        for i in a:
            nm += (i-1)//mid
        if nm > k:
            l = mid+1
        else:
            r = mid

    print(r)

    return None

if __name__ == '__main__':
    main()

Solution (Python):
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)

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

Solution (Python):
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)

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

l, r = 0, 10 ** 9
while r - l > 1:
    x = (l + r) // 2

    cnt = 0
    for i in range(n):
        if a[i] % x == 0:
            cnt += a[i] // x - 1
        else:
            cnt += a[i] // x

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

print(r)

Solution (Python):
def main():
    n, k = 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()

Solution (Python):
def binsearch(good, bad, fn):
    while abs(good - bad) > 1:
        m = (good + bad) // 2
        if fn(m):
            good = m
        else:
            bad = m
    return good

def main():
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    def fn(t):
        k = 0
        for a in A:
            k += (a - 1) // t
        return k <= K

    return binsearch(10** 9, 0, fn)

print(main())

Solution (Python):


import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,k,*a = [int(i) for i in read().split()]



def check(x,k):
    
    v = 0
    for ai in a:
        v += (ai-1)//x
    return v <= k


ok = 10**9
ng = 0
while ok-ng > 1:
    mid = (ok+ng)//2
    if check(mid,k): ok = mid
    else: ng = mid

print(ok)

Solution (Python):
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)

Solution (Python):
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
A = list(map(int, input().split()))
lb, ub = 0, 10**9
while ub - lb > 1:
    m = (lb + ub) // 2
    cnt = 0
    for i in range(N):
        cnt += (A[i] + m - 1) // m - 1
    if cnt <= K:
        ub = m
    else:
        lb = m
print(ub)

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

if sum(A)-n <= k:
    print(1)
    exit()
elif k == 0:
    print(max(A))
    exit()
top = 10**9
bottom = 1
def ok(x):
    res = 0
    for a in A:
        res += (a-1)//x
    return res <= k
while top - bottom > 1:
    mid = (top + bottom)//2
    if ok(mid):
        top = mid
    else:
        bottom = mid
print(top)

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

ok = max(a)
ng = 0
for _ in range(50):
    mid = (ok+ng)//2
    if(mid==0):
        print(1)
        exit()
    cnt = 0
    for ai in a:
        cnt += (ai-1)//mid
    if(cnt <= k):
        ok = mid
    else:
        ng = mid

print(ok)

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

while l < r:
    m = (l + r) // 2
    cnt = 0
    for v in a:
        if m == 0:
            cnt += 2 * v
        else:
            cnt += (v + m - 1) // m - 1
    if cnt <= k:
        r = m
    else:
        l = m + 1

print(l)

Solution (Python):
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)

Solution (Python):
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(int, input().split()))

def check(x):
  k = 0
  for i in range(N):
    if a[i] > x:
      k += a[i] // x
  return k <= K

ok = 10 ** 9 + 1
ng = 0
while ok - ng > 1:
  m = (ok + ng) // 2
  if check(m): ok = m
  else: ng = m
print(ok)

Solution (Python):
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)

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip('\r\n')

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

lo = 1
hi = max(A) + 1

def ceildiv(a, b):
	return (a + b - 1) // b

while lo < hi:
	tar = (lo + hi) // 2

	cuts = 0
	for v in A:
		x = ceildiv(v, tar)
		cuts += x - 1
		if cuts > K:
			lo = tar + 1
			break
	else:
		hi = tar

print(lo)

Solution (Python):
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)

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

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

def solve(mid):
    c=0
    for x in A:
        c+=-(-x//mid)-1
    return K>=c

print(nibutan(10**9,0))

Solution (Python):
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))

Solution (Python):
def solve(mid):
    cnt = 0
    for i in range(n):
        cnt += (a[i] - 1) // mid
    return cnt <= k


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

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

Solution (Python):
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n, k = nm()
    a = nl()
    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)
    return

solve()

Solution (Python):
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)

Solution (Python):
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n, k = na()
a = na()

def nu(h, a):
    ret = 0
    for v in a:
        ret += (v-1) // h
    return ret

if sum(a) - n <= k:
    print(1)
else:
    low = 0
    high = 1000000007
    while high - low > 1:
        h = (high+low)//2
        if nu(h, a) <= k:
            high = h
        else:
            low = h
    print(high)

Solution (Python):
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 i in a:
    ans+=0--i//mid-1
  if ans<=k:ok=mid
  else:ng=mid
print(ok)

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n):
    res = [None] * n
    for i in range(n):
        res[i] = II()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI()
    return res
def FR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR_(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI_()
    return res
def SR(n):
    res = [None] * n
    for i in range(n):
        res[i] = S()
    return res
def LSR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LS()
    return res
mod = 1000000007
inf = float('INF')


def solve():
    n,k = LI()
    a = LI()
    def f(x):
        tmp = 0
        for ai in a:
            tmp += int(ai / x) - (ai % x == 0)
        return tmp <= k
    ok = 10 ** 9
    ng = 0
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if f(mid):
            ok = mid
        else:
            ng = mid
    print(ok)
    return



if __name__ == '__main__':
    solve()