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: Runtime Error

Solution code:
n, k = [int(_) for _ in input().rstrip().split(" ")]
logs = [int(_) for _ in input().rstrip().split(" ")]
r = 2*10**5
l = 0
while True:
  if l >= r:
    break
  
  m = (l + r) // 2
  cnt = 0
  for a_log in logs:
    if a_log % m == 0:
      cnt += a_log//m -1
    else:
      cnt += a_log//m
  
  if cnt > k:
    l = m + 1
  else:
    r = m

print(r)

Submission status: Runtime Error

Solution code:
n, k = [int(_) for _ in input().rstrip().split(" ")]
logs = [int(_) for _ in input().rstrip().split(" ")]
r = max(logs)
l = 0
while True:
  if l >= r:
    break
  
  m = (l + r) // 2
  cnt = 0
  for a_log in logs:
    cnt += a_log //m-(a_log % m == 0)
  
  if cnt > k:
    l = m + 1
  else:
    r = m

print(r)

Submission status: Runtime Error

Solution code:
n, k = [int(_) for _ in input().rstrip().split(" ")]
logs = [int(_) for _ in input().rstrip().split(" ")]
r = max(logs)
l = 0
while True:
  if l >= r:
    break
  m = (l + r) // 2
  cnt = 0
  for a_log in logs:
    cnt += a_log //m-(a_log % m == 0)
  if cnt > k:
    l = m + 1
  else:
    r = m
print(r)

Submission status: Runtime Error

Solution code:
n, k = [int(_) for _ in input().rstrip().split(" ")]
logs = [int(_) for _ in input().rstrip().split(" ")]
r = 2*10**5
l = 0
while True:
  print(l, r)
  if l == r:
    break
  m = (l + r) // 2
  cnt = 0
  for a_log in logs:
    cnt += a_log // m - (a_log % m == 0)
  if cnt > k:
    l = m + 1
  else:
    r = m
print(l)

Submission status: Runtime Error

Solution code:
n, k = [int(_) for _ in input().rstrip().split(" ")]
logs = [int(_) for _ in input().rstrip().split(" ")]
r = max(logs)
l = 0
while True:
  if l == r:
    break
  m = (l + r)//2
  cnt = 0
  for a_log in logs:
    cnt += a_log//m
  if cnt > k:
    l = m + 1
  else:
    r = m
print(l)

Submission status: Runtime Error

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

A = list(map(int, input().split()))
d = [0] * N

#二分探索
min1 = 0
max1 = max(A)

while True:
    X = (min1 + max1)//2
    for i in range(N):
        if A[i] % X == 0:
            d[i] = A[i]//X - 1
        else:
            d[i] = A[i]//X
    if sum(d) <= K:
        max1 = X 
    else:
        min1 = X
    print(min1, max1)

    if max1 - min1 <= 1:
        print(int(max1))
        break

Submission status: Runtime Error

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

A = list(map(int, input().split()))
d = [0] * N

#二分探索
min = 1
max = max(A)

while True:
    X = (min + max)//2
    for i in range(N):
        if a[i] % X == 0:
            d[i] = A[i]//X - 1
        else:
            d[i] = A[i]//X
    if sum(d) <= K:
        max = X 
    else:
        min = X
    #print(min, max)

    if max - min <= 1:
        print(int(max))
        break

Submission status: Runtime Error

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

import math

A = list(map(int, input().split()))
d = [0] * N

#二分探索
min = 1
max = max(A)

while True:
    X = (min + max)//2
    for i in range(N):
        if a[i] % X == 0:
            d[i] = A[i]//X - 1
        else:
            d[i] = A[i]//X
    if sum(d) <= K:
        max = X 
    else:
        min = X
    #print(min, max)
    
    if max - min <= 1:
        print(int(max))
        break

Submission status: Runtime Error

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

import math

A = list(map(int, input().split()))
d = [0] * N

#二分探索
min = 1
max = max(A)

while True:
    X = (min + max)//2
    for i in range(N):
        if a[i] % X == 0:
            d[i] = A[i]//X - 1
        else:
            d[i] = A[i]//X
    if sum(d) <= K:
        max = X 
    else:
        min = X
    #print(min, max)
    
    if max - min <= 1:
        print(int(max))
        break

Submission status: Runtime Error

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

import math

A = list(map(int, input().split()))
d = [0] * N

#二分探索
min = 1
max = max(A)

while True:
    X = (min + max)//2
    for i in range(N):
        d[i] = math.ceil(A[i]/X) - 1
    if sum(d) <= K:
        max = X - 1
    else:
        min = X + 1
    #print(min, max)
    
    if min == max:
        print(int(max))
        break

Submission status: Runtime Error

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

A = list(map(int, input().split()))
d = [0] * N

#二分探索
min = 0
max = max(A)

while True:
    X = (min + max)//2
    for i in range(N):
        d[i] = A[i]//X
    if sum(d) <= K:
        max = X
    else:
        min = X
    #print(min, max)
    
    if min + 1 == max:
        print(int(max))
        break

Submission status: Runtime Error

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

A = list(map(int, input().split()))
d = [0] * N

#二分探索
min = 0
max = max(A)

while True:
    X = (min + max)//2
    for i in range(N):
        d[i] = A[i]//X
    if sum(d) <= K:
        max = X
    else:
        min = X
    print(min, max)
    
    if min + 1 == max:
        print(int(max))
        break

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

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

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

low=0
high=max(A)

while low!=high:
    mid=(low+high)//2
    s=0
    for i in range(n):
        s+=math.ceil(A[i]/mid)-1
    if s>k:
        low=mid+1
    else:
        high=mid


print(low)

Submission status: Runtime Error

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

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

left = 0
right = 10 ** 9

# able(X) を、すべての丸太を X 以下の長さに切れる場合 1 , そうでない場合 0 を返す関数とする
# 二分探索によって、able(X) が 1 に切り替わる X 点を見つける


def able(x):
    count = 0
    for i in range(N):
        if A[i] % x:
            count += A[i] // x
        else:
            count += A[i] // x - 1

    if count <= K:
        return True
    else:
        return False


while left < right:
    mid = left + (right - left) // 2
    if able(mid):
        right = mid
    else:
        left = mid + 1

print(left)

Submission status: Runtime Error

Solution code:
import pandas as pd
N,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
tmp = pd.DataFrame(A,columns=['input'])
tmp["flg"] = 1
for i in range(K):
    tmp["ans"] = tmp["input"]/ tmp["flg"] 
    tmp.iloc[tmp['ans'].idxmax(),1] = tmp.iloc[tmp['ans'].idxmax(),1] +1
tmp["ans"] = tmp["input"]/ tmp["flg"] 
print(int(tmp['ans'].max()))

Submission status: Runtime Error

Solution code:
import pandas as pd
N,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
tmp = pd.DataFrame(A,columns=['input'])
tmp["flg"] = 1
for i in range(K):
    tmp["ans"] = tmp["input"]/ tmp["flg"] 
    tmp.iloc[tmp['ans'].idxmax(),1] = tmp.iloc[tmp['ans'].idxmax(),1] +1
tmp["ans"] = tmp["input"]/ tmp["flg"] 
print(tmp['ans'].max())

Submission status: Runtime Error

Solution code:
def General_Binary_Search(L,R,cond,Integer=True,ep=1/(1<<20)):
    """一般的な二部探索を行う.
    L:解の下限
    R:解の上限
    cond:条件(1変数関数,単調減少を満たす)
    Integer:解を整数に制限するか?
    ep:Integer=Falseのとき,解の許容する誤差
    """

    if Integer:
        R+=1
        while R-L>1:
            C=L+(R-L)//2
            if cond(C):
                L=C
            else:
                R=C
        return L
    else:
        C=(R-L)/2
        while (R-C)>ep:
            if cond(C):
                L=C
            else:
                R=C
            C=L+(R-L)/2
        return C
#======================================
N,K=map(int,input().split())
A=list(map(int,input().split()))

def f(x):
    r=0
    for a in A:
        r+=(a+x-1)//x
    return r-N

print(-General_Binary_Search(-max(A),0,lambda x:f(-x)<=K))

Submission status: Runtime Error

Solution code:
import math

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

A = []
N = int(input())
K = int(input())
ans = 0

l = 0
r = 10 ** 9

for _ in range(N):
  A.append(int(input()))

while r - l > 1:
  x = (r + l) // 2
  if is_ok(A, x, K):
    r = x
  else:
    l = x
      
print(r)

Submission status: Runtime Error

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


def f(n):
    cnt = 0
    for a in A:
            # a/nが偶数の場合
        if a % n == 0:
            cnt += a//(n-1)
        # a/nが奇数の場合
        else:
            cnt += a//n
    return True if K >= cnt else False


l = 0
r = max(A)
# 二分探索
while r - l > 1:
    m = (r+l)//2
    if f(m):
        r = m
    else:
        l = m
print(r)

Submission status: Runtime Error

Solution code:
def f(n):
    cnt = 0
    for a in A:
            # a/nが偶数の場合
        if a % n == 0:
            cnt += a//(n-1)
        # a/nが奇数の場合
        else:
            cnt += a//n
    return True if K >= cnt else False


N, K = map(int, input().split())
A = list(map(int, input().split()))
l = 0
r = max(A)
# 二分探索
while r - l > 1:
    cnt = 0
    m = (r+l)//2
    if f(m):
        r = m
    else:
        l = m
print(r)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
l = 0
r = max(A)
# 二分探索
while r - l > 1:
    cnt = 0
    flag = False
    m = (r+l)//2
    for a in A:
        # a/mが偶数の場合
        if a % m == 0:
            cnt += a//(m-1)
        # a/mが奇数の場合
        else:
            cnt += a//m
    flag = True if K >= cnt else False
    # Trueなら右側を狭める
    # Falseなら左側を狭める
    if flag == True:
        r = m
    else:
        l = m
print(r)

Submission status: Runtime Error

Solution code:
def is_ok(A, x, K):
    cut_count = 0
    for number in A:
        cut_count += (number // x) - 1
    return cut_count <= K

A = []
N = int(input())
K = int(input())
ans = 0

l = 0
r = 10 ** 9

for _ in range(N):
    A.append(int(input()))

while r - l > 1:
    x = (r + l) // 2
    if is_ok(A, x, K):
        r = x       
    else:
        l = x
      
print(r)

Submission status: Runtime Error

Solution code:
# https://atcoder.jp/contests/abc174/tasks/abc174_e

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

if K == 0:
    print(max(A))
    exit()

# K回切って全ての長さをL未満にできるかどうか
def valid(L):
    # print(A, L)
    count = 0
    for a in A:
        # print(a, L, a // L, a % L)
        count += (a - 1) // L
    # print(count)
    return count <= K

# 長さLの二分探索
ng = -1
# ok = max(A) + 1
ok = 10 ** 9
while abs(ok - ng) > 1:
    m = (ok + ng) // 2
    # print(m, valid(m))
    if valid(m):
        ok = m
    else:
        ng = m
print(ok)

Submission status: Runtime Error

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

if K == 0:
    print(max(A))
    exit()

# K回切って全ての長さをL未満にできるかどうか
def valid(L):
    # print(A, L)
    count = 0
    for a in A:
        # print(a, L, a // L, a % L)
        count += a // L
    # print(count)
    return count <= K

# 長さLの二分探索
ng = -1
ok = max(A) + 1
while abs(ok - ng) > 1:
    m = (ok + ng) // 2
    # print(m, valid(m))
    if valid(m):
        ok = m
    else:
        ng = m
print(ok)

Submission status: Runtime Error

Solution code:
import math

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

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

middle = math.ceil(max(a) / 2)
oldMiddle = 0
h = middle // 2
rightMin = max(a)

while h > 0:
    cut = 0
    for i in range(n):
        cut += math.ceil(a[i] / middle) - 1
    h = math.ceil(abs(middle - oldMiddle) / 2)
    if middle == oldMiddle:
        break
    oldMiddle = middle
    if cut <= k:
        if (middle - h == rightMin):
            break
        middle -= h
    else:
        rightMin = middle
        middle += h

print(middle)

Submission status: Runtime Error

Solution code:
import math

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

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

middle = math.ceil(max(a) / 2)
oldMiddle = 0
h = middle // 2
rightMin = max(a)

while h > 0:
    cut = 0
    for i in range(n):
        cut += math.ceil(a[i] / middle) - 1
    h = math.ceil(abs(middle - oldMiddle) / 2)
    oldMiddle = middle
    if cut <= k:
        if (middle - h == rightMin):
            break
        middle -= h
    else:
        rightMin = middle
        middle += h

print(middle)

Submission status: Runtime Error

Solution code:
import math

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

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

middle = math.ceil(max(a) / 2)
oldMiddle = 0
h = 1
rightMin = max(a)

while h > 0:
    cut = 0
    for i in range(n):
        cut += math.ceil(a[i] / middle) - 1
    h = math.ceil(abs(middle - oldMiddle) / 2)
    oldMiddle = middle
    if cut <= k:
        if (middle - h == rightMin):
            break
        middle -= h
    else:
        rightMin = middle
        middle += h

print(middle)

Submission status: Runtime Error

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

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

middle = -(-(max(a) / 2) // 1)
oldMiddle = 0
h = middle // 2
rightMin = max(a)

while h > 0:
    cut = 0
    for i in range(n):
        cut += -(-((a[i] / middle) - 1) // 1)
    h = -(-(abs(middle - oldMiddle) / 2) // 1)
    oldMiddle = middle
    if cut <= k:
        if (middle - h == rightMin):
            break
        middle -= h
    else:
        rightMin = middle
        middle += h

print(int(middle))

Submission status: Runtime Error

Solution code:
import math

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

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

middle = math.ceil(max(a) / 2)
oldMiddle = 0
h = middle // 2
rightMin = max(a)

while h > 0:
    cut = 0
    for i in range(n):
        cut += math.ceil(a[i] / middle) - 1
    h = math.ceil(abs(middle - oldMiddle) / 2)
    oldMiddle = middle
    if cut <= k:
        if (middle - h == rightMin):
            break
        middle -= h
    else:
        rightMin = middle
        middle += h
    #print(middle,h,cut)

print(middle)

Submission status: Runtime Error

Solution code:
import sys
import math

input = sys.stdin.readline

def can(arr, m, K):
  need = 0
  for x in arr:
    if x > m:
      need += int(x // m)
  return need <= K

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

lo = 0
hi = int(1e9) + 1

while (lo < hi):
  m = int((lo + hi) // 2)
  if (can(arr, m, K)):
    hi = m
  else:
    lo = m + 1
print(lo)

Submission status: Runtime Error

Solution code:
import sys
import math

input = sys.stdin.readline

def can(arr, m, K):
  need = 0
  for x in arr:
    if x > m:
      need += x // m
  return need <= K

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

lo = 0
hi = int(1e9) + 1

while (lo < hi):
  m = (lo + hi) // 2
  if (can(arr, m, K)):
    hi = m
  else:
    lo = m + 1
print(lo)

Submission status: Runtime Error

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

l,r = 0,max(A)
while l<r:
	m = (l+r)//2
	s = sum([a//m+(not a%m==0)-1 for a in A])
	if s <= K:
		r = m
	else:
		l = m+1
print(r)

Submission status: Runtime Error

Solution code:
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort(revese=True)
for i in range(k):
  t=max(a)
  a.insert(0,t/2)
  a.remove(t)
print(math.ceil(max(a)))

Submission status: Runtime Error

Solution code:
# ABC174 E

import math

n, k = map(int, input().split())
a_l = [int(x) for x in input().split()]

left = 0
right = max(a_l)


def cut(len):
    ret = 0
    for i in range(n):
        ret += math.ceil(float(a_l[i] / len)) - 1
    return ret


while (right - left) > 1:
    _q = (left + right) // 2
    _ret = cut(_q)
    if k >= _ret:
        right = _q
    else:
        left = _q

_l = cut(left)
_r = cut(right)

if _l <= k:
    print(left)
else:
    print(right)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
arr=list(map(int,input().split()))
def isvalid(mid,k):
    ans=k
    for i in arr:
        if i>mid:
            ans-=i//mid
    return ans>=0


l=0
r=10**9
while(l<r):
    mid=(l+r)//2
    if isvalid(mid,k):
        r=mid
    else:
        l=mid+1
print(l)

Submission status: Runtime Error

Solution code:
from bisect import *
from heapq import *
import math
mod = 10**9+7
N, K = map(int, input().split())
A = list(map(lambda x: (-int(x), int(x), 1), input().split()))
heapify(A)
k = 0
while K > 0:
    x, _x, c1 = A[0]
    heappop(A)
    y, _y, c2 = A[0]
    c3 = math.ceil(_x/(-y))
    print(c3)
    if c3-c1 > K:
        c3 = c1+K
        K = 0
    else:
        K -= c3-c1
    heappush(A, (-(_x/c3), _x, c3))
print(math.ceil(-A[0][0]))
print(A)

Submission status: Runtime Error

Solution code:
import math
N, K = map(int,input().split())
logs = list(map(int,input().split()))
a = 0
b = max(logs)
b_memo = set()
count=0
flg =0
while math.ceil(a) != math.ceil(b):
    c = (a+b)//2
    times = []
    for i in logs:
        times.append(math.floor(i/c))
    if sum(times) > K:
        a = c
    else:
        b = c

print(math.ceil(b))

Submission status: Runtime Error

Solution code:
import math
N, K = map(int,input().split())
logs = list(map(int,input().split()))
a = 0
b = max(logs)
b_memo = set()
count=0
while math.ceil(a) != math.ceil(b):
    c = (a+b)/2
    times = []
    for i in logs:
        times.append(math.floor(i/c))
    if sum(times) > K:
        a = (a+b)/2
    else:
        b = (a+b)/2
        k = len(b_memo)
    b_memo.add(b)
    if len(b_memo) == k:
        count +=1
    if count>50:
        break        
print(math.ceil(b))

Submission status: Runtime Error

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

ok=max(alst)
ng=0

while abs(ok-ng)>0:
    cen=(ok+ng)//2

    cnt=0

    for a in alst:
        cnt+=(a+cen-1)//cen-1

    if cnt<=k:
        ok=cen
    else:
        ng=cen+1

print(ok)

Submission status: Runtime Error

Solution code:
import math
import sys
sys.setrecursionlimit(10**8)
n, k = map(int, input().split())
a = list(map(int, input().split()))
def binary_search(left, right):
    if right - left <= 0.01:
        return right
    middle = (right + left) / 2
    if is_can(middle):
        return binary_search(left, middle)
    else:
        return binary_search(middle, right)
def is_can(target):
    count = 0
    for i in range(n):
        if a[i] > target:
            count += a[i] // target
    return count <= k
p = binary_search(0, 10**10)
if is_can(int(p)) and int(p) != 0:
    print(int(p))
else:
    print(int(p) + 1)

Submission status: Runtime Error

Solution code:
import math
import sys
sys.setrecursionlimit(10**8)
n, k = map(int, input().split())
a = list(map(int, input().split()))
def binary_search(left, right):
    if right - left <= 0.01:
        return right
    middle = (right + left) / 2
    if is_can(middle):
        return binary_search(left, middle)
    else:
        return binary_search(middle, right)
def is_can(target):
    count = 0
    for i in range(n):
        if a[i] > target:
            count += a[i] // target
    return count <= k
p = binary_search(0, 10**10)
if is_can(int(p)):
    print(int(p))
else:
    print(int(p) + 1)

Submission status: Runtime Error

Solution code:
import math
import sys
sys.setrecursionlimit(10**7)
n, k = map(int, input().split())
a = list(map(int, input().split()))
def binary_search(left, right):
    if right - left <= 0.01:
        return right
    middle = (right + left) / 2
    if is_can(middle):
        return binary_search(left, middle)
    else:
        return binary_search(middle, right)
def is_can(target):
    count = 0
    for i in range(n):
        if a[i] > target:
            count += a[i] // target
    return count <= k
p = binary_search(0, 10**10)
if is_can(int(p)):
    print(is_can(int(p)))
else:
    print(int(p) + 1)

Submission status: Runtime Error

Solution code:
import math
import sys
sys.setrecursionlimit(10**7)
n, k = map(int, input().split())
a = list(map(int, input().split()))
def binary_search(left, right):
    if right - left <= 0.01:
        return right
    middle = (right + left) / 2
    if is_can(middle):
        return binary_search(left, middle)
    else:
        return binary_search(middle, right)
def is_can(target):
    count = 0
    for i in range(n):
        count += a[i] // target
    return count <= k
p = binary_search(0, 10**10)
if is_can(int(p)): 
    print(is_can(int(p)))
else:
    print(int(p) + 1)

Submission status: Runtime Error

Solution code:
import math
import sys
sys.setrecursionlimit(10**7)
n, k = map(int, input().split())
a = list(map(int, input().split()))
def binary_search(left, right):
    if right - left <= 0.01:
        return right
    middle = round((right + left) / 2, 2)
    if is_can(middle):
        return binary_search(middle, right)
    else:
        return binary_search(left, middle)
def is_can(target):
    count = 0
    for i in range(n):
        count += a[i] //target
    return count > k
print(math.ceil(round(binary_search(0,10**10),1)))

Submission status: Runtime Error

Solution code:
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))
def binary_search(left, right):
    if right - left <= 0.01:
        return right
    middle = round((right + left) / 2, 2)
    if is_can(middle):
        return binary_search(middle, right)
    else:
        return binary_search(left, middle)
def is_can(target):
    count = 0
    for i in range(n):
        count += a[i] //target
    return count > k
print(math.ceil(round(binary_search(0,10**18),1)))

Submission status: Runtime Error

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

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

def main():
    mod=10**9+7
    N,K=MI()
    A=LI()
    
    ng=-1
    ok=10**9
    
    def f(x):
        temp=0
        for i in range(N):
            temp+=(A[i]-0.1)//x
        
        return temp<=K
    
    while ok-ng>1:
        med=(ok+ng)//2
        if f(med):
            ok=med
        else:
            ng=med
               
    print(ok)
    

main()

Submission status: Runtime Error

Solution code:
import numpy as np

def is_cuttable(A, K, N):
    n = 0
    for a in A:
        i = np.ceil(a / N)
        n += int(i) - 1
        if n > K:
            return False
    return True

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

n_max = max(A)
n = n_max // 2
n_min = 0

while True:
    if is_cuttable(A, K, n):
        n_max = n
    else:
        n_min = n
    if n_max - n_min < 2:
        break
    n = (n_max + n_min) // 2
print(n_max)

Submission status: Runtime Error

Solution code:
import numpy as np

def is_cuttable(A, K, N):
    n = 0
    for a in A:
        i = np.ceil(a / N)
        n += int(i) - 1
        if n > K:
            return False
    return True

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

n_max = max(A)
n = n_max // 2
n_min = 0

while True:
    if is_cuttable(A, K, n):
        n_max = n
    else:
        n_min = n
    if n_max - n_min < 2:
        break
    n = (n_max - n_min) // 2 + n_min
print(n_max)

Submission status: Runtime Error

Solution code:
def solve():
    n, k = map(int, input().split())
    s = list(map(int, input().split()))

    def is_ok(x):
        res = 0
        for ss in s:
            y = ss // x
            if ss % x == 0:
                y -= 1
            res += y
        return res

    ok = -1
    ng = 10 ** 10
    while ng - ok > 1:
        mid = (ok + ng) // 2
        if is_ok(mid) > k:
            ok = mid
        else:
            ng = mid

    print(ok + 1)


solve()

Submission status: Runtime Error

Solution code:
import heapq
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

low = 1
high = 10**9

if n == 1:
    print((a[0]+k-1)//k)
    exit()

while low+1 < high:
    tmp = 0
    mid = (low + high) //2
    #print(mid)
    
    for i in range(n):
        tmp += ((a[i]+mid-1) // mid)-1
    
    if tmp <= k:
        high = mid
    else:
        low = mid
        
print(high)

Submission status: Runtime Error

Solution code:
import heapq
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

low = 1
high = 10**9

if n == 1:
    print((a[0]+k-1)//k)
    exit()

while low+1 < high:
    tmp = 0
    mid = (low + high) //2
    #print(mid)
    
    for i in range(n):
        tmp += ((a[i]+mid-1) // mid)-1
    print(tmp,mid)
    
    if tmp <= k:
        high = mid
    else:
        low = mid
        
print(high)

Submission status: Runtime Error

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

ng = 0
ok = max(a)

while ok - ng > 1:
    cnt = 0
    l = (ok + ng) // 2
    for a in A:
        cnt += (a // l) + (a % l != 0) - 1

    if cnt <= k:
        ok = l
    else:
        ng = l
print(ok)

Submission status: Runtime Error

Solution code:
import math

N, K = map(int,input().split)
A_str = input().split()

A = [int(a) for a in A_str]

A.sort(reverse = True)

for i in range(K):
  A[0] /= 2.
  A.sort(reverse=True)
  
min = A[0]
print(math.ceil(min))

Submission status: Runtime Error

Solution code:
import math

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

A.sort(reverse = True)

for i in range(K):
  A[0] /= 2.
  A.sort(reverse=True)
  
min = A[0]
print(math.ceil(min))

Submission status: Runtime Error

Solution code:
import math

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

A.sort(reverse = True)

for i in range(K):
  A[0] /= 2.
  A.sort(reverse=True)
  
min = A[0]
print(math.ceil(min))

Submission status: Runtime Error

Solution code:
import math

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

m = 0
M = max(A)

while(M-m>0):
    mm = 0

    mid = (M+m)//2
    for i in range(N):
        mm += math.ceil(A[i]/mid)-1

    if mm>K:
        m = mid+1
    else:
        M = mid

print(math.ceil(m))

Submission status: Runtime Error

Solution code:

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

l = min(A)//(k+1) 
r = max(A)
m = (l+r)//2+1

while 1:
    
    m = (l+r)//2
    
    #m以下の長さにできるか判定
    
    # A_long = A[A>m]
    n= sum( [  int((A[i]-0.1)//(m)) for i in range(len(A)) ] )
    
    # print(l,m,r,n)
    
    if n<=k:
        if r==m:
            break
        r=m-1
    else:
        if l==m:
            m+=1
            break
        l=m+1
        

        
print(m)

Submission status: Runtime Error

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

l = min(A)//(k+1) 
r = max(A)
m = (l+r)//2+1

while 1:
    
    m = (l+r)//2
    
    #m以下の長さにできるか判定
    
    # A_long = A[A>m]
    n= sum( [  int((A[i]-0.1)//(m)) for i in range(len(A)) ] )
    
    print(l,m,r,n)
    
    if n<=k:
        if r==m:
            break
        r=m-1
    else:
        if l==m:
            m+=1
            break
        l=m+1
        

        
print(m)

Submission status: Runtime Error

Solution code:

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

l = min(A)//(k+1) 
r = max(A)
m = (l+r)//2+1

while 1:
    
    m = (l+r)//2
    
    #m以下の長さにできるか判定
    
    # A_long = A[A>m]
    n= sum( [A[i]+0.1//m for i in range(len(A)) ] )
    
    # print(l,m,r,n)
    
    if n<=k:
        if r==m:
            break
        r=m-1
    else:
        if l==m:
            m=m+1
            break
        l=m+1
        

        
print(m)

Submission status: Runtime Error

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

l = min(A)//(k+1) 
r = max(A)
m = (l+r)//2+1

while 1:
    
    m = (l+r)//2
    
    #m以下の長さにできるか判定
    
    # A_long = A[A>m]
    n= sum( [A[i]//m - A[i]%m==0 for i in range(len(A)) ] )
    
    # print(l,m,r,n)
    
    if n<=k:
        if r==m:
            break
        r=m-1
    else:
        if l==m:
            m=m+1
            break
        l=m+1
        

        
print(m)

Submission status: Runtime Error

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

l = min(A)//(k+1) 
r = max(A)
m = (l+r)//2+1

while l<=r:
    
    m = (l+r)//2+1
    
    #m以下の長さにできるか判定
    
    # A_long = A[A>m]
    n= sum([A[i]//m for i in range(len(A)) ] )
    
    print(l,m,r,n)
    
    if n<=k:
        r=m-1
    else:
        l=m+1
        m=m+1

        
print(m)

Submission status: Runtime Error

Solution code:
from math import *

def trycut(val):
	ret = 0
	for i in range(n):
		ret += ceil(a[i]/val)-1
	return ret 

n,k=map(int,input().split())
a = [int(i) for i in input().split()]

low = 0
high = 1000000000
ans  =-1

while low <= high:
	mid = (low + high)//2
	cut = trycut(mid)
	if cut <= k:
		high = mid-1
		ans = mid
	else:
		low =  mid+1
print(ans)