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:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
n,k = readInts()
A = readInts()
if n == 2:
    print('---')
    exit()
def is_ok(mid):
    cnt = 0
    for i in range(n):
        cnt += (A[i]-1)//mid
        if cnt > k:
            return False
    return True




ok = max(A) + 1
ng = 0
while ok - ng > 1:
    mid = (ok+ng)//2
    if is_ok(mid):
        ok = mid
    else:
        ng = mid

print(ok)

Submission status: Wrong Answer

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

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
    print(max(a))
    while left < right:
        mid = (left + right) // 2
        if ok(mid):
            right = mid
        else:
            left = mid + 1
    print(left)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

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:
        while a > size:
            a -= size
            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)

    fail = 0
    success = right

    while True:
        mid = (left + right) // 2
        res = cut(A, k, mid)
        if res:
            right = mid - 1
            success = min(mid, success)
        else:
            left = mid + 1
            fail = max(mid, fail)
        if left == right:
            break
    print(success)
    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

low = 1
high = 10 ** 9
if K == 0:
    print(max(A))
else:
    while high - low > 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)

    print(math.ceil(mid))

Submission status: Wrong Answer

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
    print(x,b)
    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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 14 13:43:55 2020

@author: ezwry
"""
import math

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

logmin = math.ceil(sum(alist) / (n + k))
logmax = max(alist)


def howmanytimes(t, m):
    x = math.ceil(t/m) - 1
    return x


for i in range(logmin, logmax + 1):
    kaisu = 0
    for j in range(len(alist)):
        z = howmanytimes(alist[j], i)
        kaisu += z
    if kaisu == k:
        print(i)
        exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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()))
    max_A = max(A)
    left = 0
    right = max_A #[left,right)に最長の長さ
    while right-left > 0.00001:
        x = (left+right)/2
        kk = 0
        for i in range(n):
            kk += -(-A[i]//x)-1
        if kk > k:
            left = x
        else:
            right = x
    print(int(-(-right//1)))
    
    
    


if __name__=='__main__':
    main()

Submission status: Wrong Answer

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()))
    max_A = max(A)
    left = 0
    right = max_A #[left,right)に最長の長さ
    while right-left > 0.00001:
        x = (left+right)/2
        kk = 0
        for i in range(n):
            kk += -(-A[i]//x)-1
        if kk > k:
            left = x
        else:
            right = x
    print(int(-(-(left+right)//2)))
    
    
    


if __name__=='__main__':
    main()

Submission status: Wrong Answer

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()))
    max_A = max(A)
    left = 0
    right = max_A #[left,right)に最長の長さ
    while right-left > 0.001:
        x = (left+right)/2
        kk = 0
        for i in range(n):
            kk += -(-A[i]//x)-1
        if kk > k:
            left = x
        else:
            right = x
    print(int(-(-(left+right)//2)))
    
    
    


if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

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 = 0.0001

@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.ceil((ul + c)/2)
    else: #i.e. nk < K, less cuts than target
        ul = c
        c = np.floor((c + ll)/2)
        
if cut(A, ll+EPS, N) >= K:
    print(np.min((np.max(A), int(ul))))
else:
    print(int(ll))

Submission status: Wrong Answer

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

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 = 0.0001

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

c = (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.ceil((ul + c)/2)
    else: #i.e. nk < K, less cuts than target
        ul = c
        c = np.floor((c + ll)/2)
        
if cut(A, ll+EPS, N) >= K:
    print(np.min((np.max(A), int(ul))))
else:
    print(int(ll))

Submission status: Wrong Answer

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

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)/(int(K/N+1)+1))

EPS = 0.0001

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

c = (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.ceil((ul + c)/2)
    else: #i.e. nk < K, less cuts than target
        ul = c
        c = np.floor((c + ll)/2)
        

if cut(A, ll+EPS, N) >= K:
    print(np.min((np.max(A), int(ul))))
else:
    print(int(ll))

Submission status: Wrong Answer

Solution code:
import numpy as np
from numba import jit
verbose = True

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)/(int(K/N+1)+1))

EPS = 0.0001

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

c = (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.ceil((ul + c)/2)
    else: #i.e. nk < K, less cuts than target
        ul = c
        c = np.floor((c + ll)/2)
        

if cut(A, ll+EPS, N) >= K:
    print(np.min((np.max(A), int(ul))))
else:
    print(int(ll))

Submission status: Wrong Answer

Solution code:
def judge(A, x, k):
    ans = 0
    for a in A:
        ans += a // x
        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: Wrong Answer

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
while (ub-lb)>1:
    # 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: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
from math import ceil
def main(N, K, A):
    lo = -1
    hi = 10**9
    for i in range(100):
        m = (lo + hi) / 2
        if sum(ceil(a / m) - 1 for a in A) <= K: hi = m
        else: lo = m
    print(ceil(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: Wrong Answer

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)
    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**-5))

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

Submission status: Wrong Answer

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

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)
    under = 0
    r = 10**9
    for i in range(100):
        m = (under + r) / 2
        if cut_times(m) <= K: r = m
        else: under = 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: Wrong Answer

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)
    under = -1
    r = 10**9
    for i in range(100):
        m = (under + r) / 2
        if cut_times(m) <= K: r = m
        else: under = 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: Wrong Answer

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):
            cnt += A[i]//mid
        if K>=cnt:
            high = mid
        else:
            low = mid
print(high)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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)
    under = -1
    r = 10**9
    for i in range(100):
        m = (under + r) / 2
        if cut_times(m) <= K: r = m
        else: under = m
    print(ceil(r))

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

Submission status: Wrong Answer

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 = 1
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)

Submission status: Wrong Answer

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 = 1
r = 10**9
while l < 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
    if l + 1 == r:
        break
print(r)

Submission status: Wrong Answer

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 = 1
r = 10**9
while l < r:
    x = (l + r) // 2
    cnt = 0
    for i in range(n):
        cnt += a[i] // x
        if a[i] % x == 0:
            cnt -= 1
        if cnt > k:
            break
    if cnt <= k:
        r = x
    else:
        l = x
    if l + 1 == r:
        break
print(math.ceil((l + r) / 2))

Submission status: Wrong Answer

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 = 1
r = 10**9
while l < r:
    x = (l + r) // 2
    cnt = 0
    for i in range(n):
        cnt += a[i] // x
        if a[i] % x == 0:
            cnt -= 1
        if cnt > k:
            break
    if cnt <= k:
        r = x
    else:
        l = x
    print(l, r)
    if l + 1 == r:
        break
print(math.ceil((l + r) / 2))

Submission status: Wrong Answer

Solution code:
import math

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

l = 1
r = 10**9
while(r-l > 1):
  mid = int(l + (r-l)/2)
  cut = 0
  for num in nums:
    cut += math.ceil(num/mid)-1
  if cut <= K:
    r = mid
  else:
    l = mid
print(r)

Submission status: Wrong Answer

Solution code:
import math

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

l = 1
r = 10**9
while(r-l > 1):
  mid = (r+l)//2
  cut = 0
  for num in nums:
    cut += math.ceil(num/mid)-1
  if cut <= K:
    r = mid
  else:
    l = mid
print(math.ceil(r))

Submission status: Wrong Answer

Solution code:
from math import ceil
N, K = map(int,input().split())
A = list(map(int,input().split()))
def chk(L):
    cnt = 0
    for i in range(N):
        cnt += ceil(A[i]/L)-1
    return cnt <= K
l, r = 1, max(A)
while l <= r:
    m = (l+r)//2
    if chk(m):
        r = m-1
    else:
        l = m+1
print(max([x for x in [m-1,m,m+1] if x > 0 and chk(x)]))

Submission status: Wrong Answer

Solution code:
from math import ceil
N, K = map(int,input().split())
A = list(map(int,input().split()))
def chk(L):
    cnt = 0
    for i in range(N):
        cnt += ceil(A[i]/L)-1
    return cnt <= K
l, r = 1, max(A)
while l <= r:
    m = (l+r)//2
    if chk(m):
        r = m-1
    else:
        l = m+1
print(m)

Submission status: Wrong Answer

Solution code:
from math import ceil
N, K = map(int,input().split())
A = list(map(int,input().split()))
def chk(L):
    cnt = 0
    for i in range(N):
        cnt += ceil(A[i]/L)-1
    return cnt <= K
l, r = 1, max(A)
for _ in range(70):
    m = (l+r)/2
    if chk(m):
        r = m
    else:
        l = m
print(round(m))

Submission status: Wrong Answer

Solution code:
from math import floor
N, K = map(int,input().split())
A = list(map(int,input().split()))
def chk(L):
    cnt = 0
    for i in range(N):
        cnt += floor(A[i]/L)
    return cnt <= K
l, r = 1, max(A)
for _ in range(100):
    m = (l+r)/2
    if chk(m):
        r = m
    else:
        l = m
print(round(m))

Submission status: Wrong Answer

Solution code:
from math import floor
N, K = map(int,input().split())
A = list(map(int,input().split()))
def chk(L):
    cnt = 0
    for i in range(N):
        cnt += floor(A[i]/L)
    return cnt <= K
l, r = 1, max(A)
for _ in range(10000):
    m = (l+r)/2
    if chk(m):
        r = m
    else:
        l = m
print(round(m))

Submission status: Wrong Answer

Solution code:
from math import floor
from bisect import bisect_left
N, K = map(int,input().split())
A = list(map(int,input().split()))
def chk(L):
    cnt = 0
    for i in range(N):
        cnt += floor(A[i]/L)
    return cnt <= K
l, r = 1, max(A)
for _ in range(1000):
    m = (l+r)/2
    if chk(m):
        r = m
    else:
        l = m
print(round(m))

Submission status: Wrong Answer

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

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

ul = np.sum(A)/(K+1)
ll= np.max(A)/(int(K/N+1)+1)

EPS = 0.0001

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

c = (ul+ll)/2
mx = np.max(A)
while True:
    nk = cut(A, c, N)
    if verbose:
        print('c:', c, 'nk:', nk)
    prev = c
    if nk > K: # more cuts than target; larger logs can be made
        if ul-ll<EPS: break
        ll = c
        c = (ul + c)/2
    elif nk < K: # less cuts than target
        ul = c
        c = (c + ll)/2
    else: # exact
        if ul-ll<EPS and c<=mx: break
        ul = c
        c = (c + ll)/2
    if ul-ll<EPS/10: # anealing
        c += np.std(A)

print(int(np.ceil(c)))

Submission status: Wrong Answer

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

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

ul = np.sum(A)/(K+1)
ll= np.max(A)/(int(K/N+1)+1)

EPS = 0.0001

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

c = (ul+ll)/2
while True:
    nk = cut(A, c, N)
    if verbose:
        print('c:', c, 'nk:', nk)
    prev = c
    if nk > K: # more cuts than target; larger logs can be made
        if ul-ll<EPS: break
        ll = c
        c = (ul + c)/2
    else:
        if nk==K and ul-ll<EPS: break
        ul = c
        c = (c + ll)/2

print(int(np.ceil(c)))

Submission status: Wrong Answer

Solution code:
import numpy as np
verbose = False

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

ul = np.sum(A)/(K+1)
ll= np.max(A)/(int(K/N+1)+1)

EPS = 0.0001

c = (ul+ll)/2
while True:
    nk = np.sum(np.ceil(A/c))-N
    if verbose:
        print('c:', c, 'nk:', nk)
    prev = c
    if nk > K: # more cuts than target; larger logs can be made
        if ul-ll<EPS: break
        ll = c
        c = (ul + c)/2
    else:
        if nk==K and ul-ll<EPS: break
        ul = c
        c = (c + ll)/2

print(int(np.ceil(c)))

Submission status: Wrong Answer

Solution code:
def possible(x):
    global k
    cnt = 0
    for i in a:
        if i % x == 0:
            cnt += i // x - 1
        else:
            cnt += i // x

    if cnt <= k:
        return True
    return False

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

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

mini = 1
maxi = max(a)

while mini <= maxi:
    mid = (mini + maxi) // 2
    res = possible(mid)
    if res:
        maxi = mid
    else:
        mini = mid
    # print(mini, mid, maxi)

    if mini+1 >= maxi:
        if maxi < mini:
            mini, maxi = maxi, mini
        if possible(maxi):
            ans = maxi
        else:
            ans = mini
        break

print(ans)
# print(possible(4))

Submission status: Wrong Answer

Solution code:
def possible(x):
    global k
    cnt = 0
    for i in a:
        if i % x == 0:
            cnt += i // x - 1
        else:
            cnt += i // x

    if cnt <= k:
        return True
    return False

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

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

mini = 1
maxi = max(a)

while mini <= maxi:
    mid = (mini + maxi) // 2
    res = possible(mid)
    if res:
        maxi = mid
    else:
        mini = mid
    # print(mini, mid, maxi)

    if mini+1 >= maxi:
        if possible(maxi):
            ans = maxi
        else:
            ans = mini
        break

print(ans)
# print(possible(4))

Submission status: Wrong Answer

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

def judge(ans,K,A):
    cut=0
    for i in range(len(A)):
        cut+=(A[i]-1)//ans
    if cut>K:
        return False
    else:
        return True


ansp=max(A)
ansm=min(A)
ans=(ansp+ansm)//2
d=1
while ansp-ansm>d:
    
    if judge(ans,K,A):
        ansp=ans
        
    else:
        ansm=ans
        
    ans=(ansp+ansm)//2
print(ansp)

Submission status: Wrong Answer

Solution code:
import math
N, K=map(int,input().split())
A=list(map(int,input().split()))

def judge(ans,K,A):
    cut=0
    for i in range(len(A)):
        cut+=A[i]//ans
    if cut>K:
        return False
    else:
        return True


ansp=max(A)
ansm=min(A)
ans=(ansp+ansm)//2
d=1
while ansp-ansm>d:
    
    if judge(ans,K,A):
        ansp=ans
        
    else:
        ansm=ans
        
    ans=(ansp+ansm)//2
print(ansp)

Submission status: Wrong Answer

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

# xは求める長さ
def C(x):
    num = 0
    for i in range(n):
        # (a[i]-1)//x 回切る必要がある
        num += (l[i]-1)//x
    # k回以内に収まるか
    return num <= k

lb,ub = 0,max(l)
while ub-lb > 1:
    mid = (lb + ub) / 2
    # 条件を満たすならxを小さくしていく
    if C(mid):
        ub = mid
    else:
        lb = mid
    # print(lb,ub)

import math
ans = math.ceil(ub)
print(ans)