Problem:


Score : 500 points

Problem Statement

We have N logs of lengths A_1,A_2,\cdots A_N.

We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t.

Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.

Constraints

1 \leq N \leq 2 \times 10^5

0 \leq K \leq 10^9

1 \leq A_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 \cdots A_N

Output

Print an integer representing the answer.

Sample Input 1

2 3
7 9

Sample Output 1

4

First, we will cut the log of length 7 at a point whose distance from an end of the log is 3.5, resulting in two logs of length 3.5 each.

Next, we will cut the log of length 9 at a point whose distance from an end of the log is 3, resulting in two logs of length 3 and 6.

Lastly, we will cut the log of length 6 at a point whose distance from an end of the log is 3.3, resulting in two logs of length 3.3 and 2.7.

In this case, the longest length of a log will be 3.5, which is the shortest possible result. After rounding up to an integer, the output should be 4.

Sample Input 2

3 0
3 4 5

Sample Output 2

5

Sample Input 3

10 10
158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202

Sample Output 3

292638192



Sample input:
2 3
7 9


Sample output:
4

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split())
A = sorted(map(int,input().split()))
start = 0
end = A[-1]
while end - start > 1:
   l = (start + end)/2
   l = int(l)
   count = 0
   for i in range(N):
      q = A[i]/l
      if q == int(q):
         q -= 1
      count += int(q)
   if count <= K:
      end = l
   else:
      start = l
print(end)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split())
A = sorted(map(int,input().split()))
start = 0
end = A[-1]
l = (start + end)/2
while int(end) - start >= 0:
   l = (start + end)/2
   count = 0
   for i in range(N):
      q = A[i]/l
      if q == int(q):
         q -= 1
      count += int(q)
   if count > K:
      start = l
   else:
      end = l
ans = (start + end)/2
print(int(end) + 1)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split())
A = sorted(map(int,input().split()))
start = 0
end = A[-1]
l = (start + end)/2
while int(end) - int(start) >= 1:
   l = (start + end)/2
   count = 0
   for i in range(N):
      q, mod = divmod(A[i], l)
      if mod == 0.0:
         q -= 1
      count += q
   if count > K:
      start = l
   else:
      end = l
ans = (start + end)/2
print(int(end)+1)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split())
A = sorted(map(int,input().split()))
start = 0
end = A[-1]
l = (start + end)/2
while end - start > 1:
   l = (start + end)/2
   count = 0
   for i in range(N):
      count += (A[i]-1)//l
   if count > K:
      start = int(l)
   else:
      end = int(l+1)
print(int(l)+1)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split())
A = sorted(map(int,input().split()))
start = 0
end = A[-1]
while end - start != 0:
   l = (start + end)/2
   count = 0
   for i in range(N):
      count += (A[i]-1)//l
   if count > K:
      start = int(l)
   else:
      end = int(l+1)
print(int(l)+1)

Submission status: Time Limit Exceeded

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


def cut_num(a, cut_length):
    return math.ceil(a/cut_length) - 1


"""cut length N binary search
if cut num > K, search more longer cut length,
"""
l = 1
r = max(As)

ans = r
while True:
    m = (l+r)//2
    current_cut_num = sum([cut_num(a, m) for a in As])
    if current_cut_num <= K:
        r = m
    else:
        l = m

    if r - l < 1:
        break

if sum([cut_num(a, l) for a in As]) <= K:
    print(l)
else:
    print(r)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import time
sys.setrecursionlimit(int(1e6))
if False:
    dprint = print
else:
    def dprint(*args):
        pass

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

lx = 0
rx = max(A)
ans = 0
while (int(lx) < int(rx)):
    x = (rx + lx) / 2
    dprint("lx, x, rx = ", lx, x, rx)
    n = 0
    for i in range(len(A)):
        n += math.ceil(A[i] / x) - 1
        if n > k: break
    dprint("n = ", n)
    if n <= k:
        dprint(" smaller x")
        rx = x
    else:
        dprint(" cut less, bigger x")
        lx = x

ans = math.ceil(rx)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import time
sys.setrecursionlimit(int(1e6))
if False:
    dprint = print
else:
    def dprint(*args):
        pass

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

lx = 0
rx = max(A)
ans = 0
while (int(lx) < int(rx)):
    x = (rx + lx) / 2
    dprint("lx, x, rx = ", lx, x, rx)
    n = 0
    for i in range(len(A)):
        n += math.ceil(A[i] / x) - 1
    dprint("n = ", n)
    if n <= k:
        dprint(" smaller x")
        rx = x
        ans = x
    else:
        dprint(" cut less, bigger x")
        lx = x
        ans = rx

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import time
sys.setrecursionlimit(int(1e6))
if False:
    dprint = print
else:
    def dprint(*args):
        pass

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

lx = 0
rx = max(A)
ans = 0
while (int(lx) < int(rx)):
    x = (rx + lx) / 2
    dprint("lx, x, rx = ", lx, x, rx)
    n = 0
    for i in range(len(A)):
        n += math.ceil(A[i] / x) - 1
    dprint("n = ", n)
    if n <= k:
        dprint(" smaller x")
        rx = x
        ans = x
    else:
        dprint(" cut less, bigger x")
        lx = x
        ans = rx

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

Submission status: Time Limit Exceeded

Solution code:
def round_up_division(num1, num2):
# 切り上げ除算
  div = -(-num1 // num2)
  return div

def binary_search(search_range, max_num, logs):
  search_min = 1
  search_max = search_range
  # 二分探索
  while True:
    # max_numを超えない最大回数にする
    count_a = 0
    # count_aより1短い長さ
    count_b = 0
    # 最小値と最大値の中間の値を出す
    half_num = (search_min + search_max - 1) // 2 + 1
    for i in range(logs):
      # 木を切る回数は(⌈(木の長さ)//(切りたい長さ)⌉-1)回
      count_a += round_up_division(A[i], half_num) - 1
      if half_num != 1:
        count_b += round_up_division(A[i], half_num - 1) - 1
    if count_a > K:
      # 多ければ長い半分で探索
      search_min = round_up_division(search_min + search_max, 2)
    elif half_num != 1 and count_b <= K:
      # 少なければ短い半分で探索
      search_max = half_num - 1
    else:
      # count_aが最大になれば終了
      return half_num
      break

N, K = map(int, input().split())
A = list(map(int, input().split()))
length_max = binary_search(max(A), K, N)
print(length_max)

Submission status: Time Limit Exceeded

Solution code:
import heapq
import math

def solve():
    N, K = map(int, input().split())
    A = list(map(lambda a: (-float(a), -int(a), 1), input().split()))
    heapq.heapify(A)
    for _ in range(K):
        a = heapq.heappop(A)
        heapq.heappush(A, (a[1] / (a[2] + 1.0), a[1], a[2]+1))

    ans = -heapq.heappop(A)[0]
    print(math.ceil(ans))

solve()

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import time
sys.setrecursionlimit(int(1e6))
if False:
    dprint = print
else:
    def dprint(*args):
        pass

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

ki = [0] * len(A)
xv = A.copy()

def max_index(v):
    max_i = 0
    for i in range(len(v)):
        if (v[i]>v[max_i]):
            max_i = i
    return max_i

dprint("ki", ki)
dprint("xv", xv)
for i in range(k):
    max_i = max_index(xv)
    ki[max_i] += 1
    xv[max_i] = A[max_i] / (ki[max_i] + 1)
    dprint("max_i", max_i)
    dprint("ki", ki)
    dprint("xv", xv)
    
ans = math.ceil(max(xv))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from math import ceil

def BinarySearch(x):
    ans = sum([ceil(a/x)-1 for a in A])
    if ans <= K:
        return True
    else:
        return False

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

r = max(A)
l = 0
eps = 10**-7

while abs(r-l) > eps:

    m = (r+l)/2

    if BinarySearch(m):
        r = m
    else:
        l = m

print(ceil(r))

Submission status: Time Limit Exceeded

Solution code:
from math import ceil

def BinarySearch(x):
    ans = sum([ceil(a/x)-1 for a in A])
    if ans <= K:
        return True
    else:
        return False

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

r = max(A)
l = 0
eps = 10**-10

while abs(r-l) > eps:

    m = (r+l)/2

    if BinarySearch(m):
        r = m
    else:
        l = m

print(ceil(r))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N,K = [int(x) for x in input().split()]
Ls  = [int(x) for x in input().split()]
Ls = np.array(Ls)
cut = np.array([1]*N)
ans = Ls / cut

for k in range(K):
    idx = np.argmax(ans)
    cut[idx] += 1
    ans[idx] = Ls[idx] / cut[idx]
print(int(np.ceil(max(ans))))

Submission status: Time Limit Exceeded

Solution code:
from heapq import heapify, heappop, heappush
import math
N, K = map(int, input().split())
aaa = [(-a, 1, -a) for a in map(float, input().split())]
heapify(aaa)
for _ in range(K):
    _, cnt, L = heappop(aaa)
    cnt += 1
    heappush(aaa, (L / cnt, cnt, L))
print(math.ceil(-aaa[0][0]))

Submission status: Time Limit Exceeded

Solution code:
import math

ina = input()
inb = input()

n, k = map(int,ina.split())
ll1 = [i for i in map(int, inb.split())]
ll1.sort()
ideal = sum(ll1)/(n+k)
lc1 = [round(i/ideal-1) for i in ll1]
lc2 = [0 for _ in range(len(lc1))]

while k > 0:
    for i in reversed(range(n)):
        if k == 0:
            break
        if lc1[i] > 0:
            lc1[i] -= 1
            lc2[i] += 1
            k -= 1
        else:
            break

ll2 = [math.ceil(ll1[i]/(lc2[i]+1)) for i in range(n)]
print(max(ll2))

Submission status: Time Limit Exceeded

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

A.sort()
A.reverse()

divs = [1 for i in range(N)]
lens = [0+A[i] for i in range(N)]

for i in range(K) :  
  divs[0] += 1
  lens[0] = A[0] / divs[0]
  flag = True
  for ii in range(N-1) :
    if lens[ii+1] < lens[0] :
      lens = lens[1:ii+1] + [lens[0]] + lens[ii+1:]
      divs = divs[1:ii+1] + [divs[0]] + divs[ii+1:]
      A = A[1:ii+1] + [A[0]] + A[ii+1:]
      flag = False
      break
  if flag :
    lens = lens[1:] + [lens[0]]
    divs = divs[1:] + [divs[0]]
    A = A[1:] + [A[0]]

print(math.ceil(lens[0]))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

input_ = input()
input_ = input_.split(' ')
N = int(input_[0])
K = int(input_[1])

input_ = input()
input_ = input_.split(' ')
A_list = []
for i in range(N):
    A_list.append(int(input_[i]))

A_cut_list = A_list.copy()

count_list = [0] * N

for i in range(K):
    idxMax = np.argmax(A_cut_list)
    count_list[idxMax] += 1
    A_cut_list[idxMax] = A_list[idxMax] / (count_list[idxMax] + 1)

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

Submission status: Time Limit Exceeded

Solution code:
import math
N, K = map(int,input().split())
logs = list(map(int,input().split()))
a = 0
b = max(logs)
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
print(math.ceil(b))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

ok=max(alst)
ng=0

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

    cnt=0

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

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

print(int(np.ceil(ok)))

Submission status: Time Limit Exceeded

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

from math import ceil,floor
N,K=map(int,input().split())
A=list(map(int,input().split()))

L=0
R=max(A)
i=0
ans=(L+R)/2
cnt=0
right=0
left=0

while i<1000:
    i +=1
    for num in A:
        cnt += ceil(num/ans)-1
    if cnt <=K:
        R = ans
    elif cnt>=K:
        L = ans
    else:
        #print("fin",i-1,cnt,ans)
        break           
    ans = (R+L)/2
    cnt=0
        
print(ceil(ans))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

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

n_max = 10 ** 10
n_min = 0

while n_max - n_min > 1:
    n = (n_max + n_min) // 2
    if is_cuttable(n):
        n_max = n
    else:
        n_min = n
    
print(n_max)

Submission status: Time Limit Exceeded

Solution code:
from heapq import heappop, heappush, heapify

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

q = []
for x in a:
    heappush(q, (-x, 1, x))


for i in range(k):
    _, dc, p = heappop(q)
    dc += 1
    v = -(-p//dc)
    heappush(q, (-v, dc, p))


ans = 0
for x, _, _ in q: ans = max(ans, -x)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import heapq
n , k = map(int,input().split())
p = list(map(int,input().split()))
a = []
for i in range(n):
    a.append([-p[i],-p[i],1])
heapq.heapify(a)
for i in range(k):
    now , moto , kazu = heapq.heappop(a)
    heapq.heappush(a,[moto//(kazu+1),moto,kazu+1])
ans = heapq.heappop(a)
print(-ans[0])

Submission status: Time Limit Exceeded

Solution code:
# にぶたん練習
n,k=map(int,input().split())
a=list(map(int,input().split()))

# カット後のaの最大長を取り、カット数をシミュレートする。
# k以下でカット可能ならばTrueを返す。
# にぶたんは、効率良くT/Fを判定できる関数が作れるかがみそ。
def f(n):
  cnt=0
  for aa in a:
    cuta=aa
    i=0
    while cuta>n:
      i+=1
      cuta=aa/(i+1)
    cnt+=i
  if cnt>k:
    return False
  return True

# にぶたん実装
l,r=0,max(a)
while r-l>1:
  m=(r+l)//2
  if f(m):
    r=m
  else:
    l=m

# 今回は、rが必要な値。厳密な値は(l<x<=r)になるので、小数点切り上げでrとなる。
print(r)

Submission status: Time Limit Exceeded

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

l = 0
r = max(A)
for _ in range(100):
    mid = (r + l + 1) // 2
    count = 0
    for log in A:
        if log > mid:
            count += (log + mid - 1) // mid - 1
    if count <= K:
        r = mid
    else:
        l = mid

print(r)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math

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

def isOK(minVal):
	tmpK=0
	for a in A:
		# math.ceil(a//minVal)-1
		tmpK+=((-(-a//minVal))-1)

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

ok = max(A)
ng = 0

for i in range(50):
	mid = (ok+ng) / 2
	if isOK(mid):
		ok = mid
	else:
		ng = mid

print(math.ceil(ok))

Submission status: Time Limit Exceeded

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

for j in range(K):
    y = A.pop()
    z = y[0]*(y[1]+1)/(y[1]+2)
    zz = y[1]+1
    bisect.insort(A,[z,zz])
print(math.ceil(A[-1][0]))

Submission status: Time Limit Exceeded

Solution code:
import heapq
n, k = map(int, input().split())
list_A = list(map(int, input().split()))
list_H = []

for a in list_A:
    list_H.append(((-1)*a, a, 1))
heapq.heapify(list_H)

for _ in range(k):
    l = heapq.heappop(list_H)
    c = 0
    if l[1] % (l[2]+1) == 0:
        c = l[1] // (l[2]+1)
    else:
        c = l[1] // (l[2]+1) + 1

    h = ((-1)*c, l[1], l[2]+1)
    heapq.heappush(list_H, h)

ans = heapq.heappop(list_H)
print(abs(ans[0]))

Submission status: Time Limit Exceeded

Solution code:
import heapq
n, k = map(int, input().split())
list_A = list(map(int, input().split()))
list_H = []

for a in list_A:
    heapq.heappush(list_H, ((-1)*a, a, 1))

for _ in range(k):
    l = heapq.heappop(list_H)
    c = 0
    if l[1] % (l[2]+1) == 0:
        c = l[1] // (l[2]+1)
    else:
        c = l[1] // (l[2]+1) + 1

    h = ((-1)*c, l[1], l[2]+1)
    heapq.heappush(list_H, h)

ans = heapq.heappop(list_H)
print(abs(ans[0]))

Submission status: Time Limit Exceeded

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n,k = lr()
a = lr()

def getK(num):
    ret = 0
    for tmp in a:
        while tmp > num:
            tmp = tmp/2
            ret+=1
    return ret

ans = 0
l = 0
r = max(a)
while l <= r:
    mid = l + (r-l) // 2
    if getK(mid) < k:
        r = mid
    else:
        l = mid+1
    if l > r:
        ans = r
        break
print(math.ceil(ans))

Submission status: Time Limit Exceeded

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n,k = lr()
a = lr()

def getK(num):
    ret = 0
    for tmp in a:
        while tmp > num:
            tmp = tmp/2
            ret+=1
    return ret

ans = 0
l = 0
r = max(a)
while l <= r:
    mid = l + (r-l) // 2
    if getK(mid) < k:
        r = mid
    else:
        l = mid+1
    if l > r:
        ans = mid
        break
print(math.ceil(ans))

Submission status: Time Limit Exceeded

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
    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(100):
    if m==1:
        break
    rfm=rf(m)
    if rfm<=(n+k) and rf(m-1)>(n+k):
        break
    if um-lm<5:
        break
    if rfm>(n+k):
        lm=m
        m=(um+lm)//2-1
    elif rfm<(n+k):
        um=m
        m=(um+lm)//2-1
    else:
        um=m-1
        m=(um+lm)//2-1

if um<1:
    print(1)
    sys.exit()
    
for mi in range(um,max(0,lm-1),-1):
    if rf(mi)<=(n+k) and rf(mi-1)>(n+k):
        break

print(mi)

Submission status: Time Limit Exceeded

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
    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(60):
    if m==1:
        break
    rfm=rf(m)
    if rfm<=(n+k) and rf(m-1)>(n+k):
        break
    if um-lm<5:
        break
    if rfm>(n+k):
        lm=m
        m=(um+lm)//2-1
    elif rfm<(n+k):
        um=m
        m=(um+lm)//2-1
    else:
        um=m-1
        m=(um+lm)//2-1

if um<1:
    print(1)
    sys.exit()
    
for mi in range(um,max(0,lm-1),-1):
    if rf(mi)<=(n+k) and rf(mi-1)>(n+k):
        break

print(mi)

Submission status: Time Limit Exceeded

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
    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(60):
    if m==1:
        break
    if rf(m)<=(n+k) and rf(m-1)>(n+k):
        break
    if um-lm<5:
        break
    if rf(m)>(n+k):
        lm=m
        m=(um+lm)//2-1
    elif rf(m)<(n+k):
        um=m
        m=(um+lm)//2-1
    else:
        um=m-1
        m=(um+lm)//2-1

if um<1:
    print(1)
    sys.exit()
    
for mi in range(um,max(0,lm-1),-1):
    if rf(mi)<=(n+k) and rf(mi-1)>(n+k):
        break
print(mi)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
#from bisect import bisect_left

n, k = map(int, input().split())
*a, = map(int, input().split())
# def is_ok(arg):
#     # 条件を満たすかどうか？問題ごとに定義
#     return sum(-(-i // arg) - 1 for i in a) <= 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
#     return ok
# print(meguru_bisect(0, max(a)))
import math
import heapq
b = [(-i,1) for i in a]
heapq.heapify(b)
for _ in range(k):
    p, q = heapq.heappop(b)
    heapq.heappush(b, (p*q/(q+1),q+1))
print(math.ceil(-heapq.heappop(b)[0]))

Submission status: Time Limit Exceeded

Solution code:
import math
n, k = map(int, input().split())
aas = list(map(int, input().split()))
left = 1
right = 10**9
def judge(mid):
    cut = 0
    for i in aas:
        cut += math.ceil(i / mid) - 1
    if cut <= k:
        return True
    else:
        return False
while left < right:
    mid = (left + right) / 2
    if math.ceil(left) == math.ceil(right):
        break
    elif judge(mid):
        right = mid
    else:
        left = mid
print(math.ceil(left))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math
N,K = (int(x) for x in input().split())
a = np.array(list(map(float, input().split())))
array = np.ones(N*3).reshape((3, N))
array[[0,2],:] = [a,a]
for i in range(K):
    m = np.argmax(array[2])
    array[[1,2], m] = [array[1,m] + 1, array[0,m] / (array[1,m] + 1)]
print(math.ceil(np.max(array[2])))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math
# N,Kを入力
N,K = (int(x) for x in input().split())
# Aの数列をN項だけ入力し、配列aを作成
a = np.array(list(map(float, input().split())))
# N*2の全項が0の配列arrayを作成
array = np.ones(N*3).reshape((3, N))
# aをarrayの1行目に代入し、aがある0行目をもとに降順にソート
array[[0,2],:] = [a,a]
s_array = array[:, np.argsort(array[2])[::-1]]

# print(s_array)

# 大きいものから丸太を切っていく。長さは無視し、どの丸太を何回切ったかのみを記録
for i in range(K):
    m = np.argmax(s_array[2])
    s_array[1,m] += 1
    s_array[2,m] = s_array[0,m] / s_array[1,m]
    # s_array = s_array[:, np.argsort(s_array[2])[::-1]]

# print(s_array)
print(math.ceil(np.max(s_array[2])))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math
# N,Kを入力
N,K = (int(x) for x in input().split())
# Aの数列をN項だけ入力し、配列aを作成
a = np.array(list(map(float, input().split())))
# N*2の全項が0の配列arrayを作成
array = np.ones(N*3).reshape((3, N))
# aをarrayの1行目に代入し、aがある0行目をもとに降順にソート
array[[0,2],:] = [a,a]
s_array = array[:, np.argsort(array[2])[::-1]]

# print(s_array)

# 大きいものから丸太を切っていく。長さは無視し、どの丸太を何回切ったかのみを記録
for i in range(K):
    s_array[1,np.argmax(s_array[2])] += 1
    s_array[2,np.argmax(s_array[2])] = s_array[0,np.argmax(s_array[2])] / s_array[1,np.argmax(s_array[2])]
    # s_array = s_array[:, np.argsort(s_array[2])[::-1]]

# print(s_array)
print(math.ceil(np.max(s_array[2])))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math
# N,Kを入力
N,K = (int(x) for x in input().split())
# Aの数列をN項だけ入力し、配列aを作成
a = np.array(list(map(float, input().split())))
# N*2の全項が0の配列arrayを作成
array = np.ones(N*3).reshape((3, N))
# aをarrayの1行目に代入し、aがある0行目をもとに降順にソート
array[[0,2],:] = [a,a]
s_array = array[:, np.argsort(array[2])[::-1]]

# print(s_array)

# 大きいものから丸太を切っていく。長さは無視し、どの丸太を何回切ったかのみを記録
for i in range(K):
    s_array[1,0] += 1
    s_array[2,0] = s_array[0,0] / s_array[1,0]
    s_array = s_array[:, np.argsort(s_array[2])[::-1]]

# print(s_array)
print(math.ceil(np.max(s_array[2])))

Submission status: Time Limit Exceeded

Solution code:
import math

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

for i in range(1, max_a):
    cnt = 0
    for a in A:
        cnt += math.ceil(a/i) - 1
    
    if cnt <= K:
        print(i)
        exit()
print(max_a)

Submission status: Time Limit Exceeded

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

a = list(map(int, input().split()))
a.sort(reverse=True)
lst = []
for i in a:
    lst.append([-i, 0])

heapq.heapify(lst)

for i in range(K):
    p = heapq.heappop(lst)
    p[1] += 1
    p[0] = p[0] * p[1] / (p[1] + 1)
    heapq.heappush(lst, p)
p = heapq.heappop(lst)
print(math.ceil(-p[0]))

Submission status: Time Limit Exceeded

Solution code:
from heapq import heappush, heappop, heapify
import math
def solve():
	n , k= map(int, input().strip().split())
	# if k >= 10*8:
	# 	return 1
	a= [(-int(x),1,int(x)) for x in input().strip().split()]
	heapify(a)
	for i in range(k):
		x,cnt,orig = heappop(a)
		heappush(a,(-((orig+cnt)//(cnt+1)),cnt+1,orig))
	return -(heappop(a)[0])
 
 
print(solve())

Submission status: Time Limit Exceeded

Solution code:
from heapq import heappush, heappop, heapify
import math
def solve():
	n , k= map(int, input().strip().split())
	a= [(-int(x),1,int(x)) for x in input().strip().split()]
	heapify(a)
	for i in range(k):
		x,cnt,orig = heappop(a)
		if x == -1:
			return 1
		heappush(a,(-((orig+cnt)//(cnt+1)),cnt+1,orig))
	return -(heappop(a)[0])


print(solve())

Submission status: Time Limit Exceeded

Solution code:
from heapq import heappush, heappop, heapify
import math
def solve():
	n , k= map(int, input().strip().split())
	a= [(-int(x),1,int(x)) for x in input().strip().split()]
	heapify(a)
	for i in range(k):
		x,cnt,orig = heappop(a)
		if x == 1:
			return 1
		heappush(a,(-((orig+cnt)//(cnt+1)),cnt+1,orig))
	return -(heappop(a)[0])


print(solve())

Submission status: Time Limit Exceeded

Solution code:
from heapq import heappush, heappop, heapify
import math
def solve():
	n , k= map(int, input().strip().split())
	a= [(-int(x),1,int(x)) for x in input().strip().split()]
	heapify(a)
	for i in range(k):
		x,cnt,orig = heappop(a)
		if -x < 1:
			return 1
		heappush(a,(-((orig+cnt)//(cnt+1)),cnt+1,orig))
	return -(heappop(a)[0])


print(solve())

Submission status: Time Limit Exceeded

Solution code:
from heapq import heappush, heappop, heapify
import math
def solve():
	n , k= map(int, input().strip().split())
	a= [(-int(x),1,int(x)) for x in input().strip().split()]
	heapify(a)
	for i in range(k):
		x,cnt,orig = heappop(a)
		heappush(a,(-((orig+cnt)//(cnt+1)),cnt+1,orig))
	return -(heappop(a)[0])


print(solve())

Submission status: Time Limit Exceeded

Solution code:
# logs
# A <= X*p
# 3 <= 1.3 * 3 = 3.9
# p >= A/X = 2.... -> ceil -> 3
# 切る回数n = 別れた数p - 1
import math, bisect
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
x = 1
while True:
	cut = 0
	pos = bisect.bisect_right(a, x) # ここから右はxより大きい
	for i in range(pos, n):
		cut += math.ceil(a[i]/x) - 1
	if cut <= k:
		print(x)
		break
	x += 1