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:
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 = LI()
    if K==0:
        print(max(A))
        return
    l = 0; r = inf
    while(r-l>1):
        now = (l+r)//2
        cnt = 0
        for a in A:
            cur = a//now
            cnt += cur
        if cnt<=K:
            r = now
        else:
            l = now
        #print(now,cnt)
        #input()
    ans = r

    print(ans)
    return

def examF():
    # 0は絶対に入れない!!
    class Bit():
        def __init__(self, n):
            self.size = n
            self.tree = [0] * (n + 1)
            return

        def sum(self, i):
            s = 0
            while i > 0:
                s += self.tree[i]
                i -= i & -i
            return s

        def add(self, i, x=1):
            # i==0 はだめ => 全部+1するとか
            while i <= self.size:
                self.tree[i] += x
                i += i & -i
            return

        def search(self, x):
            # 二分探索。和がx以上となる最小のインデックス(>= 1)を返す
            # maspyさんの参考　よくわかってない
            i = 0
            s = 0
            step = 1 << ((self.size).bit_length() - 1)
            while step:
                if i + step <= self.size and s + self.tree[i + step] < x:
                    i += step
                    s += self.tree[i]
                step >>= 1
            return i + 1

        def debug(self, k):
            return [self.sum(i) for i in range(k)]

        def inversion(self, A=[3, 10, 1, 8, 5]):
            res = 0
            for i, p in enumerate(A):
                self.add(p, 1)
                res += i + 1 - self.sum(p)
            return res
    N, Q = LI()
    C = LI()
    LR = []
    lastAppeared = [-1]*N
    for i in range(Q):
        l, r = LI()
        LR.append((l,r,i))
    LR.sort(key=lambda x:x[1])
    #print(LR)
    bit = Bit(N+1)
    ans = [0]*Q
    r = 0
    now = 0
    while(r<N):
        if now==Q:
            break
        l0, r0, i0 = LR[now]
        while(r<r0):
            c = C[r]-1
            if lastAppeared[c]>0:
                bit.add(lastAppeared[c],-1)
            lastAppeared[c] = r+1
            bit.add(lastAppeared[c]+1)
            r += 1
        #print(bit.debug(r))

        while(now<Q):
            l0,r0,i0 = LR[now]
            if r<r0:
                break
            #print(r,now)
            ans[i0] = bit.sum(r0)
            if l0>1:
                ans[i0] -= bit.sum(l0-1)
            now += 1


    for v in ans:
        print(v)
    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 = 1<<60
_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 = 9

sys.setrecursionlimit(10**5)

if __name__ == '__main__':
    examE()

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

Submission status: Wrong Answer

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 = LI()
    if K==0:
        print(max(A))
        return
    l = 0; r = inf
    while(r-l>1):
        now = (l+r)//2
        cnt = 0
        for a in A:
            cur = a//now
            cnt += cur
        if cnt<=K:
            r = now
        else:
            l = now
        #print(now,cnt)
        #input()
    ans = r

    print(ans)
    return

def examF():
    # 0は絶対に入れない!!
    class Bit():
        def __init__(self, n):
            self.size = n
            self.tree = [0] * (n + 1)
            return

        def sum(self, i):
            s = 0
            while i > 0:
                s += self.tree[i]
                i -= i & -i
            return s

        def add(self, i, x=1):
            # i==0 はだめ => 全部+1するとか
            while i <= self.size:
                self.tree[i] += x
                i += i & -i
            return

        def search(self, x):
            # 二分探索。和がx以上となる最小のインデックス(>= 1)を返す
            # maspyさんの参考　よくわかってない
            i = 0
            s = 0
            step = 1 << ((self.size).bit_length() - 1)
            while step:
                if i + step <= self.size and s + self.tree[i + step] < x:
                    i += step
                    s += self.tree[i]
                step >>= 1
            return i + 1

        def debug(self, k):
            return [self.sum(i) for i in range(k)]

        def inversion(self, A=[3, 10, 1, 8, 5]):
            res = 0
            for i, p in enumerate(A):
                self.add(p, 1)
                res += i + 1 - self.sum(p)
            return res
    N, Q = LI()
    C = LI()
    LR = []
    lastAppeared = [-1]*N
    for i in range(Q):
        l, r = LI()
        LR.append((l,r,i))
    LR.sort(key=lambda x:x[1])
    #print(LR)
    bit = Bit(N+1)
    ans = [0]*Q
    r = 0
    now = 0
    while(r<N):
        if now==Q:
            break
        l0, r0, i0 = LR[now]
        while(r<r0):
            c = C[r]-1
            if lastAppeared[c]>0:
                bit.add(lastAppeared[c],-1)
            lastAppeared[c] = r+1
            bit.add(lastAppeared[c]+1)
            r += 1
        #print(bit.debug(r))

        while(now<Q):
            l0,r0,i0 = LR[now]
            if r<r0:
                break
            #print(r,now)
            ans[i0] = bit.sum(r0)
            if l0>1:
                ans[i0] -= bit.sum(l0-1)
            now += 1


    for v in ans:
        print(v)
    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 = 1<<30
_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 = 9

sys.setrecursionlimit(10**5)

if __name__ == '__main__':
    examE()

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

Submission status: Wrong Answer

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 = LI()
    if K==0:
        print(max(A))
        return
    l = 0; r = inf
    while(r-l>1):
        now = (l+r)//2
        cnt = 0
        for a in A:
            cur = a//now
            cnt += cur
        if cnt<=K:
            l = now
        else:
            r = now
        #print(now,cnt)
        #input()
    ans = r

    print(ans)
    return

def examF():
    # 0は絶対に入れない!!
    class Bit():
        def __init__(self, n):
            self.size = n
            self.tree = [0] * (n + 1)
            return

        def sum(self, i):
            s = 0
            while i > 0:
                s += self.tree[i]
                i -= i & -i
            return s

        def add(self, i, x=1):
            # i==0 はだめ => 全部+1するとか
            while i <= self.size:
                self.tree[i] += x
                i += i & -i
            return

        def search(self, x):
            # 二分探索。和がx以上となる最小のインデックス(>= 1)を返す
            # maspyさんの参考　よくわかってない
            i = 0
            s = 0
            step = 1 << ((self.size).bit_length() - 1)
            while step:
                if i + step <= self.size and s + self.tree[i + step] < x:
                    i += step
                    s += self.tree[i]
                step >>= 1
            return i + 1

        def debug(self, k):
            return [self.sum(i) for i in range(k)]

        def inversion(self, A=[3, 10, 1, 8, 5]):
            res = 0
            for i, p in enumerate(A):
                self.add(p, 1)
                res += i + 1 - self.sum(p)
            return res
    N, Q = LI()
    C = LI()
    LR = []
    lastAppeared = [-1]*N
    for i in range(Q):
        l, r = LI()
        LR.append((l,r,i))
    LR.sort(key=lambda x:x[1])
    #print(LR)
    bit = Bit(N+1)
    ans = [0]*Q
    r = 0
    now = 0
    while(r<N):
        if now==Q:
            break
        l0, r0, i0 = LR[now]
        while(r<r0):
            c = C[r]-1
            if lastAppeared[c]>0:
                bit.add(lastAppeared[c],-1)
            lastAppeared[c] = r+1
            bit.add(lastAppeared[c]+1)
            r += 1
        #print(bit.debug(r))

        while(now<Q):
            l0,r0,i0 = LR[now]
            if r<r0:
                break
            #print(r,now)
            ans[i0] = bit.sum(r0)
            if l0>1:
                ans[i0] -= bit.sum(l0-1)
            now += 1


    for v in ans:
        print(v)
    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 = 1<<30
_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 = 9

sys.setrecursionlimit(10**5)

if __name__ == '__main__':
    examE()

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

Submission status: Wrong Answer

Solution code:

import numpy as np
import sys


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


N, K = acinput()
A = np.array(sorted(acinput(), reverse=True))


def bisect_search(f, l=0, r=10**6):
    while abs(r-l) > 1:
        c = (l+r)/2
        if f(c):
            r = c
        else:
            l = c
    return c


def f(d):
    n = 0
    i = 0
    NN = A/d
    for tmp in NN:
        if tmp < 1:
            break
        n += np.ceil(tmp)-1

    return n <= K


res = bisect_search(f, l=0.01, r=A[0]+1)

if res == False:
    res = A[-1]
    print(res)
    sys.exit()

d = res
n = np.ceil(np.array(A)/d)


d2 = [0]*(N)
for i in range(N):
    d2[i] = A[i]/n[i]

print(int(np.ceil(max(d2))))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from math import ceil
# from numba import njit
# input = stdin.readline


# k回以内にすべての長さをl以下にできるか
def isDividable(l,k,a):
  cnt = 0
  for L in a:
    cnt += ceil(L // l)
  return cnt <= k


#bottom = ng,top = ok
def binary_search(ng,ok,k,a):
  while abs(ng-ok) > 1:
    mid = (ng + ok) // 2
    if isDividable(mid,k,a):
      ok = mid
    else:
      ng = mid
  return ok


# @njit
def solve(k,a):
  return binary_search(0,max(a),k,a)



def main():
  N,K = map(int,input().split())
  a = list(map(int,input().split()))
  print(solve(K,a))
  return

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import math

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

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

print(math.ceil(mid))

Submission status: Wrong Answer

Solution code:
import math

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

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

print(math.ceil(mid))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(rt)

Submission status: Wrong Answer

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


def is_ok(arg):
    # 条件を満たすかどうか？問題ごとに定義
    cut = 0
    for a in A:
        cut += (a + arg - 1)//arg - 1
    return cut <= k

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
#        print(ok, ng)
    return ok

meguru_bisect(0, 10**9+1)

Submission status: Wrong Answer

Solution code:

import numpy as np
import sys


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


N, K = acinput()
A = np.array(sorted(acinput(), reverse=True))


def bisect_search(f, val=0, l=0, r=10**6):

    # is_increase=(f(r)-f(l))>=0

    eps = 10**(-5)
    while True:

        c = (l+r)/2
        if f(c) == val:
            return c
        # if f(c)-val < eps:
        #    return c

        if f(c) < val:
            r = c

        else:
            l = c

        if l >= r:
            return False


def f(d):
    n = 0
    i = 0
    tmp = A/d
    while True:
        tmp = A[i]
        if tmp < 1:
            break
        n += np.ceil(tmp)-1
        i += 1
        if i >= len(A):
            break
    return n


res = bisect_search(f, K, l=0.01, r=A[0]+1)

if res == False:
    res = A[-1]
    print(res)
    sys.exit()

d = res
n = np.ceil(np.array(A)/d)


d2 = [0]*(N)
for i in range(N):
    d2[i] = A[i]/n[i]

print(int(np.ceil(max(d2))))

Submission status: Wrong Answer

Solution code:
#import numpy as np
#import collections
#import math

#f = open('./input_E.txt')
#
#N,K = map(int, f.readline().split())
#A = list(map(int, f.readline().split()))

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

A.sort(reverse=True)

def nibu(small,big,KK,AA):
    mid = (small+big)//2
    k_list = [(x+1)//mid for x in AA]
    sum_k = sum(k_list)
    if sum_k <= KK: #達成可能 -> 答えはもっと小さい
        return small,mid # 不可能,可能
    else:
        return mid,big # 不可能,可能


if K==0:
    ans = A[0]
else:    
    lmin = 0
    lmax = A[0]
    
    while lmax - lmin >= 2:
        lmin, lmax = nibu(lmin,lmax,K,A)
    
    ans = lmax
    
print(ans)

Submission status: Wrong Answer

Solution code:
#import numpy as np
#import collections
#import math

#f = open('./input_E.txt')
#
#N,K = map(int, f.readline().split())
#A = list(map(int, f.readline().split()))

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

A.sort(reverse=True)

def nibu(small,big,KK,AA):
    mid = (small+big)//2
    k_list = [x//mid for x in AA]
    sum_k = sum(k_list)
    if sum_k <= KK: #達成可能 -> 答えはもっと小さい
        return small,mid # 不可能,可能
    else:
        return mid,big # 不可能,可能


if K==0:
    ans = A[0]
else:    
    lmin = 0
    lmax = A[0]
    
    while lmax - lmin >= 2:
        lmin, lmax = nibu(lmin,lmax,K,A)
    
    ans = lmax
    
print(ans)

Submission status: Wrong Answer

Solution code:
#import numpy as np
#import collections
#import math

#f = open('./input_E.txt')
#
#N,K = map(int, f.readline().split())
#A = list(map(int, f.readline().split()))

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

A.sort(reverse=True)

def nibu(small,big):
    mid = (small+big)//2
#    k_list = [x//mid for x in A2]
    k_list = [x//mid for x in A]
    sum_k = sum(k_list)
    if sum_k <= K: #達成可能 -> 答えはもっと小さい
        return small,mid # 不可能,可能
    else:
        return mid,big # 不可能,可能


if N==1 or K==0:
    ans = A[0]
else:    
#    All_length = sum(A)
#    KK = K+N-1
#    lmin = int(All_length/(KK+1))
    lmin = 0
    
#    A2 = [x for x in A if x > lmin]
    
#    Kper1 = K//len(A2)
    
#    lmax = int(A[0]/(Kper1+1)) + 1
    lmax = A[1]
    
    while lmax - lmin >= 2:
        lmin, lmax = nibu(lmin,lmax)
    
    ans = lmax
    
print(ans)

Submission status: Wrong Answer

Solution code:
#import numpy as np
#import collections
#import math

#f = open('./input_E.txt')
#
#N,K = map(int, f.readline().split())
#A = list(map(int, f.readline().split()))

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

A.sort(reverse=True)

def nibu(small,big):
    mid = (small+big)//2
    k_list = [x//mid for x in A2]
    sum_k = sum(k_list)
    if sum_k <= K: #達成可能 -> 答えはもっと小さい
        return small,mid # 不可能,可能
    else:
        return mid,big # 不可能,可能


if N==1 or K==0:
    ans = A[0]
else:    
    All_length = sum(A)
    KK = K+N-1
    lmin = int(All_length/(KK+1))
    
    A2 = [x for x in A if x > lmin]
    
    Kper1 = K//len(A2)
    
    lmax = int(A[0]/(Kper1+1)) + 1
    
    while lmax - lmin >= 2:
        lmin, lmax = nibu(lmin,lmax)
    
    ans = lmax
    
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def is_ok(K, N, A, length):
    s = 0
    for i in range(N):
        if A[i] > length:
            s += math.ceil(A[i] / length)-1
    return K >= s


N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
if K == 0:
    print(A[-1])
    exit()
ok = A[-1]
ng = 1
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if is_ok(K, N, A, mid):
        ok = mid
    else:
        ng = mid

print(math.ceil(ok))

Submission status: Wrong Answer

Solution code:
import sys

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

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

def rf(mm):
    if mm==0:
        mm=1
#        return sum(a)
    icnt=0
    for i in range(n):
        icnt+=(a[i]-1)//mm+1
    return icnt

asum=sum(a)
m=asum//(n+k)
um=asum
lm=1
for ii in range(600):
#    print(ii,m)
    if rf(m)>(n+k):
        lm=m
        m=(um+lm)//2
    elif rf(m)<(n+k):
        um=m
        m=(lm+um)//2
    elif rf(m)==n+k and rf(m-1)==n+k:
        um=m
        m=(lm+um)//2
    else:
#        print(m)
        break

#for mi in range(m,0,-1):
#    if rf(mi)!=(n+k):
#        break
print(m)

Submission status: Wrong Answer

Solution code:
import math
def is_ok(K, N, A, length):
    s = 0
    for i in range(N):
        if A[i] > length:
            s += math.ceil(A[i] / length)-1
    return K >= s


N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
if K == 0:
    print(A[-1])
    exit()
ok = 10**9
ng = 1
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if is_ok(K, N, A, mid):
        ok = mid
    else:
        ng = mid

print(math.ceil(ok))

Submission status: Wrong Answer

Solution code:
import math
def solve(K, N, A, length):
    s = 0
    for i in range(N):
        if A[i] > length:
            s += int(A[i] / length)
    return K >= s


N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
if K == 0:
    print(A[-1])
    exit()
ok = 10**9
ng = 1
while abs(ok - ng) > 1:
    mid = int((ok + ng) / 2)
    if solve(K, N, A, mid):
        ok = mid
    else:
        ng = mid

print(math.ceil(ok))

Submission status: Wrong Answer

Solution code:
import math
def solve(K, N, A, length):
    s = 0
    for i in range(N):
        if A[i] > length:
            s += int(A[i] / length)
    return K >= s


N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
if K == 0:
    print(A[-1])
    exit()
ok = 10**9
ng = 1
while abs(ok - ng) > 1:
    mid = (ok + ng) / 2
    if solve(K, N, A, mid):
        ok = mid
    else:
        ng = mid

print(math.ceil(ok))

Submission status: Wrong Answer

Solution code:
import math
def solve(K, N, A, length):
    s = 0
    for i in range(N):
        if A[i] > length:
            s += int(A[i] / length)
    return K >= s


N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
if K == 0:
    print(A[-1])
    exit()
ok = 10**9
ng = 1
while abs(ok - ng) > 1:
    mid = (ok + ng) / 2
    if solve(K, N, A, mid):
        ok = mid
    else:
        ng = mid

print(math.ceil(mid))

Submission status: Wrong Answer

Solution code:
import math
def solve(K, N, A, length):
    s = 0
    for i in range(N):
        if A[i] > length:
            s += int(A[i] / length)
    return K >= s


N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
if K == 0:
    print(A[-1])
    exit()
ok = 10**9
ng = 1
while abs(ok - ng) > 1:
    mid = (ok + ng) / 2
    print(mid)
    if solve(K, N, A, mid):
        ok = mid
    else:
        ng = mid

print(math.ceil(mid))

Submission status: Wrong Answer

Solution code:
import numpy as np

def binsearch(x,low,high):
    mid=(low+high)//2
    if mid==low: return x
    mask=np.array([mid]*N)
    check=np.sum(np.ceil(logs/mask)-1)
    if check>K:
        x=binsearch(x,mid,high)
    else:
        x=binsearch(mid,low,mid)
    return x
N,K=[int(x) for x in input().split(" ")]
logs=np.array([int(x) for x in input().split(" ")])
print(binsearch(0,0,max(logs)))

Submission status: Wrong Answer

Solution code:
import math

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

floor = 1
ceil = max(a)


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


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

print(ceil)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
 
floor = 1
ceil = max(a)
L = (ceil + floor)//2
 
 
def cut(long, logs):
    cnt = 0
    for i in logs:
        cnt += (i / long) - 1
        if i % long != 0:
            cnt += 1
    return cnt
 
 
while ceil - floor > 1:
    L = (ceil + floor)//2
    num = cut(L, a)
    if num > k:
        floor = L
    else:
        ceil = L
 
print(ceil)

Submission status: Wrong Answer

Solution code:
import math

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

floor = 1
ceil = max(a)
L = (ceil + floor)//2


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


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

print(ceil)

Submission status: Wrong Answer

Solution code:
import sys

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

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

def rf(mm):
    if mm==0:
        return sum(a)
    icnt=0
    for i in range(n):
        icnt+=(a[i]-1)//mm+1
    return icnt

asum=sum(a)
m=asum//(n+k)
um=asum
lm=1
for ii in range(1000):
#    print(ii,m)
    if rf(m)>(n+k):
        lm=m
        m=(um+m)//2
    elif rf(m)<(n+k):
        um=m
        m=(lm+m)//2
    elif rf(m-1)==n+k:
        um=m-1
        m=(lm+m)//2
    else:
#        print(m)
        break

for mi in range(m-1,lm,-1):
    if rf(mi)!=(n+k):
        break
print(m)

Submission status: Wrong Answer

Solution code:
import sys

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

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

def rf(mm):
    if mm==0:
        return sum(a)
    icnt=0
    for i in range(n):
        icnt+=(a[i]-1)//mm+1
    return icnt

asum=sum(a)
m=asum//(n+k)
um=asum
lm=1
for ii in range(1000):
#    print(ii,m)
    if rf(m)>(n+k):
        lm=m
        m=(um+m)//2
    elif rf(m)<(n+k):
        um=m
        m=(lm+m)//2
    elif rf(m-1)==n+k:
        um=m-1
        m=(lm+m)//2
    else:
#        print(m)
        break

for mi in range(m,lm,-1):
    if rf(mi)!=(n+k):
        break
print(m)

Submission status: Wrong Answer

Solution code:
import sys

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

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

def rf(mm):
    if mm==0:
        return sum(a)
    icnt=0
    for i in range(n):
        icnt+=(a[i]-1)//mm+1
    return icnt

asum=sum(a)
m=asum//(n+k)
um=asum
lm=1
for ii in range(10000):
#    print(ii,m)
    if rf(m)>(n+k):
        lm=m
        m=(um+m)//2
    elif rf(m)<(n+k):
        um=m
        m=(lm+m)//2
    elif rf(m-1)==n+k:
        um=m-1
        m=(lm+m)//2
    else:
#        print(m)
        break

#for mi in range(m,0,-1):
#    if rf(mi)!=(n+k):
#        break
print(m)

Submission status: Wrong Answer

Solution code:
import sys

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

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

def rf(mm):
    if mm==0:
        return sum(a)
    icnt=0
    for i in range(n):
        icnt+=(a[i]-1)//mm+1
    return icnt

asum=sum(a)
m=asum//(n+k)
um=asum
lm=1
for ii in range(10000):
    print(ii,m)
    if rf(m)>(n+k):
        lm=m
        m=(um+m)//2
    elif rf(m)<(n+k):
        um=m
        m=(lm+m)//2
    elif rf(m-1)==n+k:
        um=m-1
        m=(lm+m)//2
    else:
#        print(m)
        break

#for mi in range(m,0,-1):
#    if rf(mi)!=(n+k):
#        break
print(m)

Submission status: Wrong Answer

Solution code:
import sys

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

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

def rf(mm):
    if mm==0:
        return sum(a)
    icnt=0
    for i in range(n):
        icnt+=(a[i]-1)//mm+1
    return icnt

asum=sum(a)
m=asum//(n+k)
um=asum
lm=1
for ii in range(600):
    if rf(m)>(n+k):
        lm=m
        m=(um+m)//2
    elif rf(m)<(n+k):
        um=m
        m=(lm+m)//2
    elif rf(m-1)==n+k:
        um=m-1
        m=(lm+m)//2
    else:
#        print(m)
        break

for mi in range(m,0,-1):
    if rf(mi)!=(n+k):
        break
print(m)

Submission status: Wrong Answer

Solution code:
import sys

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

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

def rf(mm):
    if mm==0:
        return sum(a)
    icnt=0
    for i in range(n):
        icnt+=(a[i]-1)//mm+1
    return icnt

asum=sum(a)
m=asum//(n+k)
um=asum
lm=1
for ii in range(600):
    if rf(m)>(n+k):
        lm=m
        m=(um+m)//2
    elif rf(m)<(n+k):
        um=m
        m=(lm+m)//2
    elif rf(m-1)==n+k:
        um=m-1
        m=(lm+m)//2
    else:
#        print(m)
        break

#for mi in range(m,0,-1):
#    if rf(mi)!=(n+k):
#        break
print(m)