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: Wrong Answer

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

def f(X):
    cnt = 0
    for a in A:
        cnt += int(a/X)
    return max(1, cnt)

l = 1
r = max(A)
while r-l > 0.1:
    m = (r+l)/2
    if f(m) <= K:
        r = m
    else:
        l = m

if K == 0:
    print(max(A))
elif int(r) < r and f(r) >= K:
    print(int(r)+1)
elif f(r) >= K:
    print(int(r))
elif int(l) < l:
    print(int(l)+1)
else:
    print(int(l))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, k = map(int, input().split())
a = list(map(int, input().split()))


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


ok, ng = 0, max(a) + 1
while abs(ok - ng) > 1:
    m = (ok + ng) // 2
    if f(m) > k:
        ok = m
    else:
        ng = m
print(ok + 1)

Submission status: Wrong Answer

Solution code:
import copy
import math

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

ub = 10**9
lb = 0

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate
import math

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    N, K = map(int, input().split())
    if K > 10**7:
        print(1)
        exit()
    A = list(map(int, input().split()))
    q = []
    for i in range(N):
        heappush(q,(-A[i],0))

    for i in range(K):
        l, c = heappop(q)
        heappush(q,(l*(c+1)/(c+2),c+1))
    
    ans = 0
    while q:
        l,c = heappop(q)
        ans = max(ans,-l)
    print(math.ceil(ans))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, k = map(int, input().split())
a = list(map(int, input().split()))

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


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


ok, ng = 0, max(a)
while abs(ok - ng) > 1:
    m = (ok + ng) // 2
    if f(m) > k:
        ok = m
    else:
        ng = m
print(ok + 1)

Submission status: Wrong Answer

Solution code:
import math

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

_min = 0
_max = max(A)

while int(_min)<int(_max):
  new = (_min+_max)/2
  times = sum([math.floor(a/new) for a in A])
  #print(new, times)
  if times <= K:
    _max = new
  else:
    _min = new
    
print(math.ceil(_min))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate
import math

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    N, K = map(int, input().split())
    if K > 10**7:
        print(0)
        exit()
    A = list(map(int, input().split()))
    q = []
    for i in range(N):
        heappush(q,(-A[i],0))

    for i in range(K):
        l, c = heappop(q)
        heappush(q,(l*(c+1)/(c+2),c+1))
    
    ans = 0
    while q:
        l,c = heappop(q)
        ans = max(ans,-l)
    print(math.ceil(ans))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N):
    A[i] *= -1
import heapq
heapq.heapify(A)
for i in range(K):
    m = heapq.heappop(A)
    heapq.heappush(A,m/2)
a = min(A)
a *= -1
if a == int(a):
    print(int(a))
else:
    print(int(a) + 1)

Submission status: Wrong Answer

Solution code:
import copy
import math

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

ub = 10**9
lb = 0

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

Submission status: Wrong Answer

Solution code:
from math import ceil, floor
n,k = map(int,input().split())
a = list(map(int,input().split()))
l = 0
r = 10**9
m = (l+r)//2+1
for i in range(100):
    # print(l,m,r)
    cnt = 0
    for j in a:
        cnt += (j//m)
    # print(cnt)
    # print(l,m,r,cnt)
    if cnt <= k:
        r = m
        m = ceil((l+r)/2)
    else:
        l = m
        m = ceil((l+r)/2)
print(m)

Submission status: Wrong Answer

Solution code:
from math import ceil

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

def flag(upper):
    c = 0
    for a in A:
        c += int(a / upper)
        if c > k:
            return False
    return True

def main():
    A.sort(reverse=True)
    low = 1
    high = A[0]
    while low < high:
        mid = (low + high) // 2
        if flag(mid):
            high = mid
        else:
            low = mid + 1
    print(high)
    return

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from math import ceil

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


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


ok, ng = 0, max(a)
while abs(ok - ng) > 1:
    m = (ok + ng) // 2
    if f(m) > k:
        ok = m
    else:
        ng = m
print(ok + 1)

Submission status: Wrong Answer

Solution code:

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

    res = 0
    for v in X:
        res += v // mid

    if res <= K:
        ub = mid
    else:
        lb = mid

if K == 0:
    print(max(X))
else:
    print(ub)

Submission status: Wrong Answer

Solution code:
from math import floor, ceil


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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
A=list(map(int,input().split()))
high=max(A)
low=0
while high-low>1:
    cnt=0
    now=(low+high)//2
    for a in A:
        cnt+=max((a-1)//now,0)
        if cnt>k:
            break
    if cnt>k:
        low=now
    else:
        high=now
    print(cnt,low,high)
print(high)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate
import math

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    N, K = map(int, input().split())
    if K > 5*10**6:
        print(0)
        exit()
    A = list(map(int, input().split()))
    q = []
    for i in range(N):
        heappush(q,(-A[i],0))

    for i in range(K):
        l, c = heappop(q)
        heappush(q,(l*(c+1)/(c+2),c+1))
    
    ans = 0
    while q:
        l,c = heappop(q)
        ans = max(ans,-l)
    print(math.ceil(ans))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

def f(X):
    cnt = 0
    for a in A:
        cnt += int(a/X)
    return max(1, cnt)

l = 1
r = max(A)
while r-l > 1:
    m = (r+l)//2
    if f(m) <= K:
        r = m
    else:
        l = m

if K == 0:
    print(max(A))
elif f(r) <= K:
    print(r)
else:
    print(l)

Submission status: Wrong Answer

Solution code:
import copy
import math

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

ub = 10**9
lb = 0

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from math import ceil

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


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


ok, ng = 0, max(a)
while abs(ok - ng) > 1:
    m = (ok + ng) / 2
    if f(m) > k:
        ok = m
    else:
        ng = m
print(ceil(ok))

Submission status: Wrong Answer

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

L=a[-1]
if k==0:
    print(L)
    exit()

M=L
m=0
while M-m>=0.01:
    x=(M+m)/2
    c=0
    for p in a:
        c+=ceil(p/x)-1
        if c>k:
            break
    if c<=k:
        M=x
    else:
        m=x
    x=(M+m)/2
print(ceil((M+m)/2))

Submission status: Wrong Answer

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


a.sort()

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

def solve(num):
    ret=0
    for tmp in a:
        ret+= tmp//num
    return k>=ret

l=0
r=10**18
while r-l>1:
    mid=(l+r)//2

    if solve(mid):
        r=mid
    else:
        l=mid
print(min(max(a),r))

Submission status: Wrong Answer

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

num_cut = [1]*n
cut_list = copy.copy(a)

for i in range(k):
    max_index = cut_list.index(max(cut_list))
    num_cut[max_index] += 1
    cut_list[max_index] = a[max_index] / num_cut[max_index]
    #print("a",a)
    #print("cut_list", cut_list)
    #print("num_cut",num_cut)

print(int(max(cut_list)))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
import math
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return [LIST() for _ in range(n)]
def NSTR(n): return [input() for _ in range(n)]


INF = float("inf")
MOD = 10**9 + 7


def main():
    N, K = MAP()
    A = LIST()

    # X決め打ち二分探索
    left = 0
    right = 10**9+4
    while right - left > 1.0e-5:
        mid = (right + left) / 2
        count = 0
        for a in A:
            count += int(math.ceil(a / mid))-1
        # print(mid, count)
        if count <= K:
            right = mid
        else:
            left = mid
    # print(left, right)
    print(int(math.ceil(left)))

    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def f(X):
    cnt = 0
    for a in A:
        cnt += int(a/X)
    return max(1, cnt)

l = 1
r = max(A)
while r-l > 1:
    m = (r+l)//2
    if f(m) <= K:
        r = m
    else:
        l = m

if K == 0:
    print(max(A))
elif f(r) >= K:
    print(r)
else:
    print(l)

Submission status: Wrong Answer

Solution code:
N,K = [int(a) for a in input().split()]
A = [int(a) for a in input().split()]
m = [[]]*N
c = [1]*N
for i in range(N):
    m[i] = A[i]
for i in range(K):
    #print(m)
    I = m.index(max(m))
    c[I] += 1
    m[I] = A[I]/c[I]
print(round(max(m)))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import math


def read():
    N, K = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, K, A


def solve(N, K, A):
    if N == 1:
        if K == 0:
            return A[0]
        else:
            return math.ceil(A[0] / (K+1))
    ng = 0
    ok = max(A)
    while abs(ok-ng) > 1:
        mid = (ok+ng) // 2
        k = sum([a // mid for a in A])
        if k <= K:
            ok = mid
        else:
            ng = mid
    return ok


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from math import ceil

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


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


ok, ng = 0, max(a)
while abs(ok - ng) > 1:
    m = (ok + ng) / 2
    if f(m) > k:
        ok = m
    else:
        ng = m
print(ceil(ok) + 1)

Submission status: Wrong Answer

Solution code:
## coding: UTF-8
import bisect

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

l = []
for i in range(N):
    l.append([A[i], A[i], 1])

#print(l)

for i in range(K):
    tmp = l.pop()
    tmp[2] += 1
    tmp[0] = float(tmp[1] / tmp[2])
    bisect.insort(l, tmp)
    #print(l)

ans = l[-1][0]
#print(ans)
if((ans - ans // 1) >= 0.5):
    print(int(ans//1+1))
else:
    print(int(ans//1))

Submission status: Wrong Answer

Solution code:
n,k=map(int, input().split())
a = list(map(int, input().split()))
a=sorted(a)
if k==0:
    print(max(a))
    exit()

lo=0
hi=10**9
oldmid=0
while True:
    mid=(hi+lo)/2
    cnt=0
    for i in range(n):
        cnt+=round((a[i])/mid-0.5)
    if cnt>k:
        lo=mid
    elif cnt<=k:
        hi=mid
    if oldmid-0.001<=mid<=oldmid+0.001:
        #print(mid)
        print(round(mid))
        break
    oldmid=mid

Submission status: Wrong Answer

Solution code:
import math

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

l= 0.0
r= 1000000000.0
while(r-l>0.0001):
    mid = (l+r)/2
    abc=1
    cnt=0
    for i in range(n):
        x = math.floor(a[i]/mid)
        cnt+=int(x)
    if(cnt>k):
        abc=0
    if(abc==1):
        r=mid
    else:
        l=mid

print(int(round(r)))

Submission status: Wrong Answer

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


a.sort()

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

def solve(num):
    ret=0
    for tmp in a:
        ret+= tmp//num
    return k>=ret

l=0
r=10**18
while r-l>1:
    mid=(l+r)//2

    if solve(mid):
        r=mid
    else:
        l=mid

for i in range(max(mid-10,1),mid+10):
    if solve(i):
        print(i)
        exit()

Submission status: Wrong Answer

Solution code:
import sys
import math
input = sys.stdin.readline

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

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

def check(x):
    res = 0
    for i in a:
        res += i // x
    return res

l = 0
r = 10 ** 9 + 1
for _ in range(40):
    x = (l + r) / 2
    if check(x) >= k:
        l = x
    else:
        r = x
print(math.ceil(l))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys 
import math
sys.setrecursionlimit(10**6)
MOD = 10**9+7 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

#2分法
#K回の切断ですべてN以下にできるか
def solve(N):
    cnt = 0
    for a in A:
        if a % N ==0:
            cnt += (a//N-1)
        else:
            cnt += a//N
    if cnt <= K:
        return True
    else:
        return False

left = 0
right = 10**9+5
while right-left > 0.01:
    N = (right+left)/2
    flag = solve(N)
    if flag:
        right = N
    else:
        left = N
print(math.ceil(left))

Submission status: Wrong Answer

Solution code:
n,k = map(int, raw_input().split())
ais = map(int, raw_input().split())

def p(m,ais,k):
	for ai in ais: k-= ai / m
	return k >=0

lo,hi = 1, max(ais)

while(lo < hi):
	med = (lo + hi)/2
	if p(med, ais, k):
		hi = med
	else:
		lo = med + 1

print lo

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
import math
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return [LIST() for _ in range(n)]
def NSTR(n): return [input() for _ in range(n)]


INF = float("inf")
MOD = 10**9 + 7


def main():
    N, K = MAP()
    A = LIST()

    # X決め打ち二分探索
    left = 0
    right = 10**9
    while right - left > 1.0e-5:
        mid = (right + left) / 2
        count = 0
        for a in A:
            count += int(math.ceil(a / mid))-1
        # print(mid, count)
        if count <= K:
            right = mid
        else:
            left = mid
    # print(left, right)
    print(int(math.ceil(left)))

    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def f(x):
    cnt = k
    for i in a:
        tmp = math.ceil(i / x)
        cnt -= tmp - 1
        if cnt < 0:
            return False
    return True

n, k = LI()
a = LI()
a.sort(reverse=True)
ok = sum(a)
ng = 1
while ok - ng > 1:
    mid = (ok + ng) // 2
    if f(mid):
        ok = mid
    else:
        ng = mid
print(ok)

Submission status: Wrong Answer

Solution code:
n,k = map(int, raw_input().split())
ais = map(int, raw_input().split())

def p(m,ais,k):
	t = [ m, ais, k]
	for ai in ais:
		k-= ai / m
	return k >=0

lo,hi = 1, max(ais)
#print lo,hi
while(lo < hi):
	med = (lo + hi)/2
	if p(med, ais, k):
		hi = med
	else:
		lo = med + 1

print lo

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
A=list(map(int,input().split()))
high=max(A)
low=0
while high-low>1:
    cnt=0
    now=(low+high)//2
    for a in A:
        cnt+=a//now
        if cnt>k:
            break
    if cnt>k:
        low=now
    else:
        high=now
    #print(cnt,low,high)
print(high)

Submission status: Wrong Answer

Solution code:
n,k = map(int, raw_input().split())
ais = map(int, raw_input().split())

def p(m,ais,k):
	t = [ m, ais, k]
	for ai in ais:
		k-= ai / m
	return k >=0

lo,hi = 1, max(ais)
print lo,hi
while(lo < hi):
	med = (lo + hi)/2
	if p(med, ais, k):
		hi = med
	else:
		lo = med + 1

print lo

Submission status: Wrong Answer

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

def f(X):
    cnt = 0
    for a in A:
        cnt += int(a/X)
    return max(1, cnt)

l = 1
r = max(A)
while r-l > 0.1:
    m = (r+l)/2
    if f(m) <= K:
        r = m
    else:
        l = m

if K == 0:
    print(max(A))
elif f(int(r)+1) >= K:
    print(int(r)+1)
elif f(int(r)) >= K:
    print(int(r))

Submission status: Wrong Answer

Solution code:
import heapq

length_heap = []

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

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

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

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

print(int(result+0.5))

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
a = list(map(float,input().split()))

lf = 0e0
ri = 1e10

for i in range(100):
  md = (lf + ri) / 2
  p = 0
  for j in range(N):
    p += a[j] // md
  if p <= K:
    ri = md
  else:
    lf = md

print(round((lf+ri)/2))

Submission status: Wrong Answer

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,k=nii()
a=lnii()

ok=max(a)
ng=1

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

  num=0
  for i in a:
    num+=i//m

  if num<=k:
    ok=m
  else:
    ng=m

print(ok)

Submission status: Wrong Answer

Solution code:
import os
import sys
from io import BytesIO, IOBase
# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------------------

def RL(): return map(int, sys.stdin.readline().rstrip().split())
def RLL(): return list(map(int, sys.stdin.readline().rstrip().split()))
def N(): return int(input())
def comb(n, m): return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0
def perm(n, m): return factorial(n) // (factorial(n - m)) if n >= m else 0
def mdis(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2)
def toord(c): return ord(c)-ord('a')
def lcm(a, b): return a*b//lcm(a, b)
mod = 998244353
INF = float('inf')
from math import factorial, sqrt, ceil, floor, gcd
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush


# ------------------------------

def main():
    n, k = RL()
    arr = RLL()

    l, r = 0, max(arr)
    res = r

    def c(num):
        tk = k
        for i in range(n):
            if num!=0:
                now = arr[i]//num
            else:
                now = arr[i]//0.4
            tk-=now
        return tk>=0

    while l<=r:
        m = (l+r)//2
        if c(m):
            res = m
            r = m-1
        else:
            l = m+1
    print(res)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


def read():
    N, K = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, K, A


def solve(N, K, A):
    ng = 0
    ok = max(A)
    while abs(ok-ng) > 1:
        mid = (ok+ng) // 2
        k = sum([a // mid for a in A])
        if k <= K:
            ok = mid
        else:
            ng = mid
    return ok


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
A=list(map(int,input().split()))
high=max(A)
low=1
while high-low>1:
    cnt=0
    now=(low+high)//2
    for a in A:
        cnt+=a//now
        if cnt>k:
            break
    if cnt>k:
        low=now
    else:
        high=now
    #print(cnt,low,high)
print(high)