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



Sample input:
2 3
7 9


Sample output:
4

Submission status: Time Limit Exceeded

Solution code:
def examA():
    X = I()
    if X<30:
        ans = "No"
    else:
        ans = "Yes"
    print(ans)
    return

def examB():
    N, D = LI()
    cnt = 0
    for _ in range(N):
        x, y = LI()
        if x**2+y**2<=D**2:
            cnt += 1
    ans = cnt
    print(ans)
    return

def examC():
    N = 10**7
    K = I()
    cur = 0
    now = 1
    ans = -1
    for i in range(N):
        cur += 7 * now
        cur %= K
        if cur==0:
            ans = i+1
            break
        now *= 10
        now %= K
    print(ans)
    return

def examD():
    N = I()
    C = SI()
    cnt = 0
    l = 0; r = N-1
    while(l<r):
        while(l<N):
            if C[l]=="W":
                break
            l += 1
        while(0<=r):
            if C[r]=="R":
                break
            r -= 1
        if l<r:
            cnt += 1
            l += 1
            r -= 1
    ans = cnt
    print(ans)
    return

def examE():
    N, K = LI()
    A = LDI()
    l = 0; r = inf
    for _ in range(200):
        now = dec((l+r)/2)
        cnt = 0
        for a in A:
            cur = a//now
            cnt += cur
        if K<cnt:
            l = now
        else:
            r = now
        #print(now,cnt)
        #input()
    ans = now
    #print(now)
    if now%1>0:
        ans = (ans+1)//1
    else:
        ans = ans//1
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

def test():
    i = I()
    li = LI()
    lsi = LSI()
    si = LS()
    print(i)
    print(li)
    print(lsi)
    print(si)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep,alphabet_convert
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examE()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Submission status: Time Limit Exceeded

Solution code:
import math
n,k=map(int,input().split(" "))
a=[1 for i in range(n)]
b=list(map(int,input().split(" ")))

for i in range(k):
  M=max(b)
  s=b.index(M)
  b[s]=b[s]*a[s]
  a[s]=a[s]+1
  b[s]=b[s]/a[s]
  
print(math.ceil(max(b)))

Submission status: Time Limit Exceeded

Solution code:
def examA():
    X = I()
    if X<30:
        ans = "No"
    else:
        ans = "Yes"
    print(ans)
    return

def examB():
    N, D = LI()
    cnt = 0
    for _ in range(N):
        x, y = LI()
        if x**2+y**2<=D**2:
            cnt += 1
    ans = cnt
    print(ans)
    return

def examC():
    N = 10**7
    K = I()
    cur = 0
    now = 1
    ans = -1
    for i in range(N):
        cur += 7 * now
        cur %= K
        if cur==0:
            ans = i+1
            break
        now *= 10
        now %= K
    print(ans)
    return

def examD():
    N = I()
    C = SI()
    cnt = 0
    l = 0; r = N-1
    while(l<r):
        while(l<N):
            if C[l]=="W":
                break
            l += 1
        while(0<=r):
            if C[r]=="R":
                break
            r -= 1
        if l<r:
            cnt += 1
            l += 1
            r -= 1
    ans = cnt
    print(ans)
    return

def examE():
    N, K = LI()
    A = LDI()
    l = 0; r = inf
    for _ in range(1000):
        now = dec((l+r)/2)
        cnt = 0
        for a in A:
            cur = a//now
            cnt += cur
        if K<cnt:
            l = now
        else:
            r = now
        #print(now,cnt)
        #input()
    ans = now
    #print(now)
    if now%1>0:
        ans = (ans+1)//1
    else:
        ans = ans//1
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

def test():
    i = I()
    li = LI()
    lsi = LSI()
    si = LS()
    print(i)
    print(li)
    print(lsi)
    print(si)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep,alphabet_convert
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examE()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Submission status: Time Limit Exceeded

Solution code:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

l,h=0,max(a)
while h-l>0.0000001:
    mid=(h+l)/2
    # print(l,h,mid)
    cnt=0
    for i in range(n):
        cnt+=math.ceil(a[i]/mid)-1
    #     print(a[i]/mid)
    # print(cnt)
    if cnt<=k:
        h=mid
    else:
        l=mid

# print(l)
print(math.ceil(l-0.000001))

Submission status: Time Limit Exceeded

Solution code:
from heapq import heappop,heappush
from math import ceil
n,k=map(int,input().split())
a=list(map(int,input().split()))
hq=[]
for x in a:
	heappush(hq,[-x,1])
for i in range(k):
	r=heappop(hq)
	heappush(hq,[r[0]*r[1]/(r[1]+1),r[1]+1])
ans=-heappop(hq)[0]
print(ceil(ans))

Submission status: Time Limit Exceeded

Solution code:
from heapq import heappush, heappop
from math import ceil
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

h = []
for a in A :
  heappush(h, (-a, a, 1))
  
for _ in range(K) :
  _, x, i = heappop(h)
  heappush(h, (-(x / (i + 1)), x, i + 1))
  
print(ceil(-h[0][0]))

Submission status: Time Limit Exceeded

Solution code:
from heapq import heappop,heappush
from math import ceil
from fractions import Fraction as F
n,k=map(int,input().split())
a=list(map(int,input().split()))
hq=[]
for x in a:
	heappush(hq,[-x,1])
for i in range(k):
	r=heappop(hq)
	heappush(hq,[F(r[0]*r[1],(r[1]+1)),r[1]+1])
ans=-heappop(hq)[0]
print(ceil(ans))

Submission status: Time Limit Exceeded

Solution code:
import math
import heapq

n, k = map(int, input().split())
a = [(-int(x), 1) for x in input().split()]
heapq.heapify(a)

for i in range(k):
  key = heapq.heappop(a)
  heapq.heappush(a, (key[0]*key[1]/(key[1]+1), key[1]+1))

print(math.ceil(-heapq.heappop(a)[0]))

Submission status: Time Limit Exceeded

Solution code:
from functools import cmp_to_key
import heapq


def func(a, b):
    if a[0] * b[1] == a[1] * b[0]:
        return 0
    elif a[0] * b[1] > a[1] * b[0]:
        return - 1
    else:
        return 1


n, k = map(int, input().split())
c = cmp_to_key(func)
hq = list(map(lambda x: c((int(x), 1)), input().split()))
heapq.heapify(hq)
for _ in range(k):
    t = heapq.heappop(hq).obj
    heapq.heappush(hq, c((t[0], t[1] + 1)))
t = heapq.heappop(hq).obj
print((t[0] - 1) // t[1] + 1)

Submission status: Time Limit Exceeded

Solution code:
from heapq import heappush, heappop


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    h = []
    for a in A:
        heappush(h, [-a, a, 1])
    for i in range(K):
        pri, origlen, cut = heappop(h)
        heappush(h, [-origlen//(cut+1), origlen, cut+1])
    ans = -h[0][0]
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
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()]
    hq = []
    for i in a:
        hpq.heappush(hq,(-i,i,1))

    for i in range(k):
        ln,ai,nm = hpq.heappop(hq)
        hpq.heappush(hq,(-ai/(nm+1),ai,nm+1))

    ln,ai,nm = hpq.heappop(hq)
    print((ai-1)//nm+1)

    return None

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines

from math import ceil
def main():
    n, k = map(int, input().split())
    a = tuple(map(int, input().split()))

    def kaisu(long):
        return(sum([ceil(ae/long) - 1 for ae in a]))

    def bs_meguru(key):
        def isOK(index, key):
            if kaisu(index) <= key:
                return True
            else:
                return False
        ng = 0
        ok = max(a)
        while abs(ok - ng) > 1:
            mid = (ok + ng) // 2
            if isOK(mid, key):
                ok = mid
            else:
                ng = mid
        return ok
    print(bs_meguru(k))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
  l,r=0,10**9
  while r-l>1:
    m=(l+r)//2
    if sum([(i-1)//m for i in a])<=k: r=m;
    else: l=m;
  print(r)

if __name__=='__main__':
  n,k=map(int,input().split())
  a=list(map(int,input().split()))
  main()

Submission status: Accepted

Solution code:
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)

if __name__=='__main__':
  n,k=map(int,input().split())
  a=list(map(int,input().split()))
  main()

Submission status: Accepted

Solution code:
from sys import stdin

input = stdin.readline
import math
import heapq


def solve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    left = 1
    right = max(a)

    def ok(l):
        s = sum([(i-1) // l for i in a])
        return s <= k
    while left < right:
        mid = (left + right) // 2
        if ok(mid):
            right = mid
        else:
            left = mid + 1
    print(left)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import math

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

l, r = 0, max(A)
while r - l > 1:
    x = (l + r) // 2
    cnt = 0
    for a in A:
        n = math.ceil(a / x)
        # n = (a + x - 1) // x
        cnt += n - 1
    if cnt > K:
        l = x 
    else:
        r = x

print(r)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
ls = list(map(int,input().split()))
#二分探索
#適切にokとngを定めていきましょう
def is_ok(arg):
    # 条件を満たすかどうか？問題ごとに定義
    num = 0
    for i in range(n):
        num += -(-ls[i] // arg) -1
    if num <= k:
        return True
    return False
def meguru_bisect(ng, ok):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    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(ls)+1))

Submission status: Accepted

Solution code:
import sys
# sys.setrecursionlimit(100000)


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


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def cut(A, k, size) -> bool:
    cnt = 0
    for a in A:
        cnt += a // size
        if a % size == 0:
            cnt -= 1
        if cnt > k:
            return False
    if cnt <= k:
        return True


def main():
    n, k = input_int_list()
    A = input_int_list()

    left = 0
    right = max(A)

    while right > left + 1:
        mid = (left + right) // 2
        res = cut(A, k, mid)
        if res:
            right = mid
        else:
            left = mid
    print(right)
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

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

if K == 0:
    print(max(A))
else:
    low = 0
    high = max(A)
    while high - low > 0.1:
        mid = (low + high) / 2
        times = 0
        for a in A:
            times += math.ceil(a / mid) - 1
        if K >= times:
            high = mid
        else:
            low = mid
        #print(mid)

    ans = int(mid)
    if not ans:
        print(1)
    else:
        times = 0
        for a in A:
            times += math.ceil(a / ans) - 1
        if times <= K:
            print(ans)
        else:
            print(ans+1)

Submission status: Accepted

Solution code:
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)))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

N, K = rl()
A = rl()

def is_ok(x):
	s = 0
	for a in A:
		s += math.ceil(a / x)-1
	return s <= K

l, r = 0, 10**9
while r-l > 1:
	m = (r+l)//2
	if is_ok(m):
		r = m
	else:
		l = m
print(r)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

minz = 0
maxz = maxL+1
while minz < maxz-1:
    midz = (maxz + minz)//2
    ncut = 0
    for i in range(N):
        thiscut = int((logs[i] + midz - 1) / midz) - 1
        ncut += thiscut

    if ncut > K:
        minz = midz
    else:
        maxz = midz

print(maxz)

Submission status: Accepted

Solution code:
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))
    
    
    


if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
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, max(A), k))
    
    
    


if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np
from numba import jit
import random
verbose = False
rand = False

if rand:
    N, K = random.choice(range(10)), random.choice(range(10))
    A = np.array(random.choices(range(10**9), k=N))
else:
    N, K = list(map(int, input().split()))
    A = np.array(list(map(int, input().split())), dtype=np.int64)

ul = np.ceil(np.sum(A)/(K+1))
ll= np.floor(np.max(A)/(K+1))

EPS = 1 / 10**6

@jit(nopython=True)
def cut(A, c, N):
    return (np.sum(np.ceil(A/c))-N)

c = np.ceil((ul+ll)/2)
mx = np.max(A)
while True:
    if ul-ll <= 1:
        break
    nk = cut(A, c, N)
    if verbose:
        print('c:', c, 'nk:', nk, 'ul - ll:', ul, '/', ll)
    prev = c
    if nk  >K: # more cuts than target; larger logs can be made
        ll = c
        c = np.floor((ul + c)/2)
    else: #i.e. nk < K, less cuts than target
        ul = c
        c = np.ceil((c + ll)/2)
        
if cut(A, ll+EPS, N) >= K:
    print(np.min((np.max(A), int(ul))))
else:
    print(int(ll))

Submission status: Accepted

Solution code:
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 = map(int, open(0).read().split())
print(binary_search(0, 1_000_000_000, K))

Submission status: Accepted

Solution code:
def is_good(mid, key):
    res = 0
    for a in A:
        res += (a + mid - 1) // mid
    return res - 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 = map(int, open(0).read().split())
print(binary_search(0, 1_000_000_000, K))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
N, K = 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)
    #else ncut == K
    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)

Submission status: Accepted

Solution code:
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)))

Submission status: Accepted

Solution code:
import sys
import math
#15608119
n, k = map(int, input().split())
a = list(map(int, input().split()))

if k >= sum(a) - n: #すべての丸太の長さを1以下にできる
  print(1)
else:
  ok, ng = max(a), 1
  while ok - ng > 1: # ok - ng = 1になったら、問題の答えはokで確定
    mid = (ok+ng)//2
    if sum(math.ceil(x/mid)-1 for x in a) <= k: # 「答えがmid以下」が正しいなら
      ok = mid
    else: # 「答えがmid以下」が正しくないなら
      ng = mid
  print(ok)

Submission status: Accepted

Solution code:
from sys import stdin
import numpy as np

n, k = map(int, stdin.buffer.readline().split())
a = np.fromstring(stdin.buffer.read(), dtype=np.int, sep=' ')

ng = 0
ok = 10 ** 9 + 1
while ok - ng > 1:
    mid = (ok + ng) >> 1
    if np.sum(np.ceil(a / mid) - 1) <= k:
        ok = mid
    else:
        ng = mid
print(ok)

Submission status: Accepted

Solution code:
from sys import stdin
import numpy as np
n, k = map(int, stdin.buffer.readline().split())
a = np.fromstring(stdin.buffer.read(), dtype=np.int64, sep=' ')

ng = 0
ok = 10 ** 9 + 1
while ok - ng > 1:
    mid = (ok + ng) >> 1
    if np.sum(np.ceil(a / mid) - 1) <= k:
        ok = mid
    else:
        ng = mid
print(ok)

Submission status: Accepted

Solution code:
from sys import stdin
import numpy as np
n, k = map(int, stdin.buffer.readline().split())
a = np.array(stdin.buffer.read().split(), dtype=np.int64)

ng = 0
ok = 10 ** 9 + 1
while ok - ng > 1:
    mid = (ok + ng) >> 1
    if np.sum(np.ceil(a / mid) - 1) <= k:
        ok = mid
    else:
        ng = mid
print(ok)

Submission status: Accepted

Solution code:
from sys import stdin
import numpy as np
n, k = 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(np.ceil(a / mid) - 1) <= k:
        ok = mid
    else:
        ng = mid
print(ok)

Submission status: Accepted

Solution code:
from sys import stdin
import numpy as np
n, k = 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)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
ok = 1000000000
ng = 0

while ok-ng>1:
    count = 0
    mid = (ok+ng)//2
    for a in A:
        if a%mid==0:
            count += -1+a//mid
        else:
            count += a//mid

    if count <= K:
        ok = mid
    else:
        ng = mid
print(ok)

Submission status: Accepted

Solution code:
from sys import stdin
import numpy as np
from numba import njit, i8
n, k = map(int, stdin.readline().split())
a = np.array(stdin.readline().split(), dtype = np.int64)

@njit(cache=True)
def c(x, a):
    res = 0
    for i in range(n):
        res += 0 - - a[i] // x - 1
    return res <= k

ng = 0
ok = 10 ** 9 + 1
while ok - ng > 1:
    mid = (ok + ng) >> 1
    if c(mid, a):
        ok = mid
    else:
        ng = mid
print(ok)

Submission status: Accepted

Solution code:
from collections import deque,defaultdict,Counter
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from bisect import bisect_left,bisect_right
from math import sqrt,gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode
import sys
sys.setrecursionlimit(10 ** 6)

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse=False):
    data.sort(key=lambda x:x[col],reverse=revese)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def mydictvaluesort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[1] )

def mydictkeysort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[0] )

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

n,k = MI()
a = RI()

L = max(a)

def mycheck(l):
    count = 0
    for i in range(n):
        count += a[i]//l
    return count <= k

lb = 0
ub = L
for i in range(100):
    # print(ub,lb)
    mid = (lb+ub)/2
    # print(mid)
    flag = mycheck(mid)
    # print(flag)
    if flag:
        ub = mid
    else:
        lb = mid

ans = ceil(lb)
print(ans)

Submission status: Accepted

Solution code:
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, K, A):
    lo = 0
    hi = 10**9
    while hi - lo > 1:
        m = (lo + hi) // 2
        if sum((a + m - 1) // m - 1 for a in A) <= K: hi = m
        else: lo = m
    print(hi)

if __name__ == '__main__':
    input = sys.stdin.readline
    N, K = map(int, input().split())
    *A, = map(int, input().split())
    main(N, K, A)

Submission status: Accepted

Solution code:
# でつ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 if a > longest)
    under = 0
    r = 10**9
    for i in range(100):
        m = (under + r) / 2
        if cut_times(m) > K: under = m
        else: r = m
    print(ceil(r - 10**-10))

if __name__ == '__main__':
    input = sys.stdin.readline
    N, K = map(int, input().split())
    *A, = map(int, input().split())
    main(N, K, A)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
if K==0:
    high = max(A)
else:
    low = 0
    high = 10**9
    while high-low>1:
        mid = (high+low)//2
        cnt = 0
        for i in range(N):
            if A[i]%mid==0:
                cnt += A[i]//mid-1
            else:
                cnt += A[i]//mid
        if K>=cnt:
            high = mid
        else:
            low = mid
print(high)

Submission status: Accepted

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


def c(x):
    res = 0
    for b in a:
        # bを最大がxになるように、できるだけ少ない回数で
        # だいたいb/x等分？
        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)

Submission status: Accepted

Solution code:
# ng, ok = 0, 10**9+1

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

Submission status: Accepted

Solution code:
# region header
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
import copy
# @lru_cache(maxsize=None)
# sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7
# endregion
# region input function


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])

# endregion


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)