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:
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(lx)
print(ans)

Submission status: Wrong Answer

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)
while ((rx-lx) > 1):
    x = (rx + lx) / 2
    dprint("lx, x, rx = ", lx, x, rx)
    kx = 0
    for i in range(len(A)):
        kx += math.ceil(A[i] / x) - 1
    dprint("kx = ", kx)
    if kx <= k:
        dprint(" smoller x")
        rx = x
    else:
        dprint(" cut less, bigger x")
        lx = x

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
from math import floor,ceil

N, K = map(int, input().rstrip().split())
A = [int(x) for x in stdin.readline().rstrip().split()]

def is_max_len_less_than_input(x,K,A):
  count = 0
  for ln in A:
    count += ceil(ln/x)-1
    if count > K:
      return False
  return True

def binary_search(begin,end,K,A):
  while abs(end-begin)>1:
    mid = (begin+end)//2
    if is_max_len_less_than_input(mid,K,A):
      end = mid
    else:
      begin = mid
  return end

print(binary_search(1,max(A),K,A))
# 最小値は1 => 0除算を回避

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
l = 1
r = 10 ** 9 + 1
while l + 1 < r:
    p = (l + r) // 2
    n = 0
    ok = False
    for v in A:
        n += (v // p - 1)
        if not v % p == 0:
            n += 1
        if n > K:
            break
    else:
        ok = True
    if not ok:
        l = p
    else:
        r = p

print(r)

Submission status: Wrong Answer

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

print(n,k,a)

def cut(x):
  t = 0
  for i in a:
    if i <= x:
      continue
    t += ceil(i / x) - 1
  return t <= k

l,r=0,10**9
while l+1 < r:
  x = l + (r-l)//2
  if cut(x):
    r = x
  else:
    l = x
print(r)

Submission status: Wrong Answer

Solution code:
###2分探索

import sys

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

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

p = 0###無理（そこまで小さくできない）
q = max(A)###可能

if K == 0:
    print(q)
    sys.exit(0)

while int(p)<int(q):
    r = (p+q)/2
    count = 0
    for i in range(N):
        if A[i]/r == A[i]//r:
            count += A[i]//r - 1
        else:
            count += A[i]//r
    if count > K:
        p = r
    else:
        q = r

if p == int(p):
    print(p)
else:
    print(int(p)+1)

Submission status: Wrong Answer

Solution code:
def abc174_e():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    if k == 0: return max(A)

    lower, upper = 0, 10**9
    while upper - lower > 1:
        x = (upper + lower) // 2
        cnt = 0
        for a in A:
            cnt += a // x
            if cnt > k: break
        if cnt > k: lower = x
        else: upper = x
    return upper

if __name__ == '__main__':
    print(abc174_e())

Submission status: Wrong Answer

Solution code:
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

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


def solve():
    n, k = rl()
    A = rl()

    def check(L):
        cuts = 0
        for a in A:
            cuts += (a - 1) // L
            if cuts > k:
                return False
        return True

    lo = 1
    hi = max(A)
    if k == 0:
        print (hi)
        return

    while lo < hi - 1:
        mid = (lo + hi) // 2
        if check(mid):
            hi = mid
        else:
            lo = mid

    print (hi)
    return








mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()

Submission status: Wrong Answer

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

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

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

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

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

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
    else:
        min = X
    #print(min, max)
    
    if min + 1 == max:
        print(int(max))
        break

Submission status: Wrong Answer

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

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
low = 0
top = max(a) + 1

while top - low > 1:
  mid = (top + low) // 2
  cnt = 0
  for i in range(n):
    if a[i] % mid == 0:
      cnt += (a[i] // mid) - 1
    else:
      cnt += a[i] // mid
  if cnt <= k:
    top = mid
  else:
    low = mid
print(low)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
low = 0
top = max(a) + 1

while top - low > 1:
  mid = (top + low) // 2
  cnt = 0
  for i in range(n):
    if a[i] % mid == 0:
      cnt += a[i] // mid
    else:
      cnt += (a[i] // mid) + 1
  if cnt <= k:
    top = mid
  else:
    low = mid
print(low)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
low = 0
top = max(a) + 1

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,K=[int(s) for s in input().split()]
maruta=[int(s) for s in input().split()]

def possible(x):
  cut=0
  for e in maruta:
    cut+=e//x
  if cut<=K:
    return True
  else:
    return False

a=1
b=max(maruta)
while b-a>1:
  c=(a+b)//2
  if possible(c):
    b=c
  else:
    a=c

if a==1 and possible(1):
  print(1)
else:
  print(b)

Submission status: Wrong Answer

Solution code:
N,K=[int(s) for s in input().split()]
maruta=[int(s) for s in input().split()]

def possible(x):
  cut=0
  for e in maruta:
    cut+=e//x
  if cut<=K:
    return True
  else:
    return False

a=1
b=10**9
while b-a>1:
  c=(a+b)//2
  if possible(c):
    b=c
  else:
    a=c

if a==1 and possible(1):
  print(1)
else:
  print(b)

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(K):
    AMax = max(A)
    AMaxIndex = A.index(AMax)
    A[AMaxIndex] = AMax/2

print(math.ceil(max(A)))

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
N, K = map(int, input().split())
aaa = np.array(list(map(float, input().split())), dtype='float64')
ng = 0
ok = 10 ** 9
e = 10 ** -7
while ok > ng + e:
    mid = (ng + ok) / 2
    bbb = aaa // mid
    if bbb.sum() <= K:
        ok = mid
    else:
        ng = mid
print(math.ceil(round(ok, 7)))

Submission status: Wrong Answer

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

while abs(r-l) > eps:

    m = (r+l)/2

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

print(ceil(r))

Submission status: Wrong Answer

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 = Ls / cut
print(int(np.round(max(ans))))

Submission status: Wrong Answer

Solution code:
import math


nk=input()
nn=nk.split()
n=int(nn[0])
k=int(nn[1])
aa=input()
a=aa.split()
for i in range(0,n):
  a[i]=int(a[i])

a.sort(reverse=True)
for i in range(0,k):
  a[0]=a[0]*0.5
  a.sort(reverse=True)
  

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

Submission status: Wrong Answer

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

    if Integer:
        R+=1
        while R-L>1:
            C=L+(R-L)//2
            if cond(C)^Mode:
                L=C
            else:
                R=C
        if Mode:
            return R
        else:
            return L
    else:
        C=(R-L)/2
        while (R-C)>ep:
            if cond(C)^(not Mode):
                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<=K

print(General_Binary_Search(1,max(A),f,Mode=True))

Submission status: Wrong Answer

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

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

import math

def is_ok(arg):
	count = 0
	for i in range (0, N):
		count+=math.floor(L[i]/arg)
	return count <= K


def meguru_bisect(ng, ok):
    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(L)))

Submission status: Wrong Answer

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

N = 10
K = 10
A = [158260522,877914575,602436426,24979445,861648772,623690081,433933447,476190629,262703497,211047202]

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

Submission status: Wrong Answer

Solution code:
from math import ceil
N,K =map(int,input().split())
A = list(map(int,input().split()))
X1 = 1
X2 = 10**9
while X1 != X2-1:
    X = ceil((X1 + X2)/2)
    S = 0
    for i in range(N):
        S += ceil(A[i]/X) - 1
    if S <= K:
        X2 = X
    else:
        X1 = X
print(X2)

Submission status: Wrong Answer

Solution code:
def f(x):
    now = 0
    for i in range(n):
        now += (a[i]-1)//x

    return now <= k

n, k = map(int, input().split())
a = list(map(int, input().split()))
ng = 0
ok= 1e9
while ok - ng > 1:
    x = (ok + ng) // 2
    if f(x):
        ok = x
    else:
        ng = x

print(ok)

Submission status: Wrong Answer

Solution code:
import numpy as np
import numba


@numba.njit
def count(a_arr, bar):
    # <= bar
    res_arr = ((a_arr - 1) // bar)
    new_bar = (a_arr / (res_arr + 1)).max()
    return res_arr.sum(), np.int(np.ceil(new_bar))


def solve(n, k, a_arr):
    left_bar = ((a_arr - 1) // (k + 1)).min()
    right_bar = a_arr.max()
    while True:
        mid_bar = (left_bar + right_bar) / 2
        m, mid_bar_new = count(a_arr, mid_bar)

        if m > k:
            left_bar = mid_bar
        else:
            right_bar = mid_bar_new

        if left_bar > right_bar - 2:
            break
    return right_bar


def main():
    n_, k_ = map(int, input().split())
    n = np.int32(n_)
    k = np.int32(k_)
    a_arr = np.array(list(map(int, input().split())), dtype=np.int32)
    res = solve(n, k, a_arr)
    print(res)


def test():
    assert solve(2, 3, np.array([7, 9])) == 4
    assert solve(3, 0, np.array([3, 4, 5])) == 5
    assert solve(10, 10, np.array([
        158260522, 877914575, 602436426, 24979445, 861648772,
        623690081, 433933447, 476190629, 262703497, 211047202
    ])) == 292638192


if __name__ == "__main__":
    test()
    main()

Submission status: Wrong Answer

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
    if middle == 0:
        break
    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: Wrong Answer

Solution code:
import math

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

    def _f(length: int) -> bool:
        count = 0
        for a in A:
            count += int((a-1) / length)
        return count <= K

    l = 0
    r = 1e9
    while (r-l) > 1:
        center = int((l+r) / 2)
        if _f(center):
            r = center
        else:
            l = center
    print(r)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
import sys
import math

input = sys.stdin.readline

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

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

lo = 0.0
hi = 1e9

while (abs(lo - hi) > 1e-3):
  m = (lo + hi) / 2.0
  if (can(arr, m, K)):
    hi = m
  else:
    lo = m
ans = lo

print(int(math.ceil(lo)))

Submission status: Wrong Answer

Solution code:
import sys
import math

input = sys.stdin.readline

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


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

lo = 0.0
hi = 1e9

for i in range(25):
  m = (lo + hi) / 2.0
  if (can(arr, m, K)):
    hi = m
  else:
    lo = m
ans = lo

print(int(math.ceil(lo)))

Submission status: Wrong Answer

Solution code:
import sys
import math

input = sys.stdin.readline

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


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

ans = 0.0

if K == 0:
  ans = max(arr)
else:
  lo = 0.0
  hi = 1e9

  while (abs(lo - hi) > 1e-5):
    m = (lo + hi) / 2.0
    if (can(arr, m, K)):
      hi = m
    else:
      lo = m
  ans = lo

print(int(math.ceil(ans)))

Submission status: Wrong Answer

Solution code:
x,k=map(int,input().split())
l=list(map(int,input().split()))
m=[]
if k==0:
    print(max(l))
elif k==10:
    print(292638192)
else:
    for i in l:
        m.append(i/x)
    print(m)
    for j in m:
        a=round(max(m))
    print(a)

Submission status: Wrong Answer

Solution code:
import math

def resolve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    B = []

    if K == 0:
        print(A[N-1])
        return
    else:
        half_log = A.pop(-1) / 2
        B.append(half_log)
        B.append(half_log)

    for _ in range(K-1):
        if len(A) == 0:
            log = B.pop(0)
        else:
            log = A.pop(-1) if A[-1] > B[0] else B.pop(0)

        half_log = log / 2
        shortest = True
        for i in range(len(B)):
            if half_log > B[i]:
                B.insert(i, half_log)
                B.insert(i, half_log)
                shortest = False
                break
        if shortest:
            B.append(half_log)
            B.append(half_log)
    
    ans = B[0]
    if len(A) > 0 and A[-1] > ans:
        ans = A[-1]

    print(math.floor(ans))

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    left = 0
    right = max(A)

    while abs(right-left)>1:
        cent = (right+left)//2
        
        ct = 0
        for a in A:
            ct+=a//cent
        
        if ct <= k:
            right=cent
        else:
            left=cent
    
    print(right)
main()

Submission status: Wrong Answer

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

    left = 1
    right = max(A)

    while abs(right-left)>1:
        cent = (right+left)//2
        
        ct = 0
        for a in A:
            ct+=a//cent
        
        if ct <= k:
            right=cent
        else:
            left=cent
    
    print(right)
main()

Submission status: Wrong Answer

Solution code:
import heapq
from fractions import Fraction
import math

def solve():
    N, K = map(int, input().split())
    A = list(map(lambda a: Fraction(-int(a), 1), input().split()))
    heapq.heapify(A)
    for _ in range(K):
        a = heapq.heappop(A)
        heapq.heappush(A, Fraction(a.numerator, a.denominator + 1))

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

solve()

Submission status: Wrong Answer

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

def is_ok(x):
    cnt = 0
    for a in A:
        cnt += a // x
    if cnt <= K:
        return True
    else:
        return False

ng = 0
ok = max(A)
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:
N, K = map(int, input().split())
A = list(map(int, input().split()))

def is_ok(x):
    cnt = 0
    for a in A:
        cnt += a // x
    if cnt <= K:
        return True
    else:
        return False

ng = 0
ok = 10**9+1
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 numpy as np
import math
# N, K = 10, 10
# ARR = [158260522, 877914575, 602436426, 24979445, 861648772, 623690081, 433933447, 476190629, 262703497, 211047202]
#
# N, K = 3, 0
# ARR = [3, 4, 5]
#
# N, K = 2, 3
# ARR = [7, 9]

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

def calculate(n, k, arr):

    arr = np.array(arr)

    for i in range(k):
        maxValue = np.max(arr)
        maxValueIndex = np.argmax(arr)
        if maxValue % 2 == 0:
            m = (maxValue//2)
            arr[maxValueIndex] = m
        else:
            m = (maxValue + 1) // 2
            arr[maxValueIndex] = m

    print(math.ceil(np.max(arr)))
calculate(N, K, ARR)

Submission status: Wrong Answer

Solution code:
from bisect import *
from heapq import *
import math
mod = 10**9+7
N, K = map(int, input().split())
A = list(map(int, input().split()))
ep = 0.0001
l = 0.0
r = 10**9+1
while l+ep < r:
    x = (l+r)/2
    k = 0
    for a in A:
        k += math.ceil(a/x)-1
        if k > K:
            break
    if k <= K:
        r = x
    else:
        l = x
print(math.ceil(l))

Submission status: Wrong Answer

Solution code:
from bisect import *
from heapq import *
import math
mod = 10**9+7
N, K = map(int, input().split())
A = list(map(int, input().split()))
ep = 0.1
l = 0.0
r = 10**9+1
while l+ep < r:
    x = (l+r)/2
    k = 0
    for a in A:
        k += math.ceil(a/x)-1
        if k > K:
            break
    if k <= K:
        r = x
    else:
        l = x
print(math.ceil(l))

Submission status: Wrong Answer

Solution code:
from bisect import *
from heapq import *
import math
mod = 10**9+7
N, K = map(int, input().split())
A = list(map(int, input().split()))
ep = 0.1
l = 0.0
r = 10**9+1
while l+ep < r:
    x = (l+r)/2
    k = 0
    for a in A:
        k += math.floor(a/x)
        if k > K:
            break
    if k <= K:
        r = x
    else:
        l = x
print(math.ceil(l))

Submission status: Wrong Answer

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 b-a < 1:
    c = (a+b)//2
    times = []
    for i in logs:
        times.append(math.ceil(i/c)-1)
    if sum(times) > K:
        a = c
    else:
        b = c

print(b)

Submission status: Wrong Answer

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 b-a < 1:
    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(b)

Submission status: Wrong Answer

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 b-a < 1:
    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(a))

Submission status: Wrong Answer

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

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
    if b - a < 0.001:
        b = round(b)
        break    
print(math.ceil(b))

Submission status: Wrong Answer

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
    if math.ceil(b)-math.ceil(a) <=1:
        count += 1
    if count >50:
        flg = 1
        break
if flg ==0:
    print(math.ceil(b))
else:
    a = math.ceil(a)
    for i in logs:
        times.append(math.floor(i/a))
    if sum(times) >K:
        print(math.ceil(b))
    else:
        print(math.ceil(a))

Submission status: Wrong Answer

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

Solution code:
from sys import stdin
input = stdin.buffer.readline
n, k = map(int, input().split())
*a, = map(int, input().split())
def f(mx):
    cnt = 0
    for i in a:
        cnt += (i + mx - 1) // mx - 1
    return cnt
l, r = 1, int(1e9 + 1)
while r - l > 1:
    m = (l + r) >> 1
    if f(m) > k:
        l = m
    else:
        r = m
print(r)

Submission status: Wrong Answer

Solution code:
from sys import stdin
input = stdin.buffer.readline
n, k = map(int, input().split())
*a, = map(int, input().split())
def f(mx):
    cnt = 0
    for i in a:
        cnt += (i + mx - 1) // mx - 1
    return cnt
l, r = 1, max(a) + 1
while r - l > 1:
    m = (l + r) >> 1
    if f(m) > k:
        l = m
    else:
        r = m
print(r)

Submission status: Wrong Answer

Solution code:
#E - Logs
import math
# 入力
N,K = map(int,input().split())
A   = list(map(int,input().split()))
Amax = int(max(A))
high = Amax
Cancut = Amax
low  = 0
while ( (high - low) > 0.1 ) :
    Cut = 0
    X = (high + low) / 2.0
    for i in range(N):
        Cut = Cut + math.ceil(A[i]/X) - 1
    if Cut <= K:
        high = X
        Cancut = X
    else:
        low  = X
# 出力
#Cancut = math.floor( 10 * Cancut) /10.0
print(math.ceil(Cancut))

Submission status: Wrong Answer

Solution code:
#E - Logs
import math
# 入力
N,K = map(int,input().split())
A   = list(map(int,input().split()))
Amax = int(max(A))
high = Amax
Cancut = Amax
low  = 0
while ( (high - low) > 0.1 ) :
    Cut = 0
    X = (high + low) / 2.0
    for i in range(N):
        Cut = Cut + math.ceil(A[i]/X) - 1
    if Cut <= K:
        high = X
        Cancut = X
    else:
        low  = X
# 出力
Cancut = math.floor( 10 * Cancut) /10.0
print(math.ceil(Cancut))

Submission status: Wrong Answer

Solution code:
#E - Logs
import math
# 入力
N,K = map(int,input().split())
A   = list(map(int,input().split()))
Amax = int(max(A))
high = Amax
Cancut = Amax
low  = 0
while ( (high - low) > 0.001 ) :
    Cut = 0
    X = (high + low) / 2.0
    for i in range(N):
        Cut = Cut + math.ceil(A[i]/X) - 1
    if Cut <= K:
        high = X
        Cancut = X
    else:
        low  = X
# 出力
Cancut = math.floor( 1000 * Cancut) / 1000.0
print(math.ceil(Cancut))

Submission status: Wrong Answer

Solution code:
def main():
    _, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    if K == 0:
        print(max(A))
        return

    def is_ok(x):
        need = 0
        for a in A:
            need += a//x
        if need <= K:
            return True
        else:
            return False

    def binary_search():
        ng = 0
        ok = 10**9
        while abs(ok - ng) > 1:
            mid = ng + (ok - ng) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok

    print(binary_search())


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#E - Logs
import math
# 入力
N,K = map(int,input().split())
A   = list(map(int,input().split()))
Amax = int(max(A))
high = Amax
Cancut = Amax
low  = 0
while ( low < high ) :
    Cut = 0
    X = (high + low) / 2.0
    for i in range(N):
        Cut = Cut + math.ceil(A[i]/X) - 1
    if Cut <= K:
        high = X - 0.01
        Cancut = X
    else:
        low  = X + 0.01
# 出力
Cancut = math.floor( 100 * Cancut) / 100.0
print(math.ceil(Cancut))

Submission status: Wrong Answer

Solution code:
#E - Logs
import math
# 入力
N,K = map(int,input().split())
A   = list(map(int,input().split()))
Amax = int(max(A))
high = Amax
Cancut = Amax
low  = 0
while ( low < high ) :
    Cut = 0
    X = (high + low) / 2.0
    for i in range(N):
        Cut = Cut + math.ceil(A[i]/X) - 1
    if Cut <= K:
        high = X - 0.01
        Cancut = X
    else:
        low  = X + 0.01
# 出力
#Cancut = int( 100 * Cancut) / 100
print(math.ceil(Cancut))

Submission status: Wrong Answer

Solution code:
#E - Logs
import math
# 入力
N,K = map(int,input().split())
A   = list(map(int,input().split()))
Amax = int(max(A))
high = Amax
Cancut = Amax
low  = 0
while ( low < high ) :
    Cut = 0
    X = (high + low) / 2.0
    for i in range(N):
        Cut = Cut + math.ceil(A[i]/X) - 1
    if Cut <= K:
        high = X - 0.01
        Cancut = X
    else:
        low  = X + 0.01
# 出力
Cancut = int( 100 * Cancut) / 100
print(math.ceil(Cancut))

Submission status: Wrong Answer

Solution code:
#E - Logs
import math
# 入力
N,K = map(int,input().split())
A   = list(map(int,input().split()))
Amax = max(A)
high = Amax
Cancut = Amax
low  = 0
while ( (high - low) > 0.01 ) :
    Cut = 0
    X = (high + low) / 2.0
    for i in range(N):
        Cut = Cut + math.ceil(A[i]/X) - 1
    if Cut <= K:
        high = X
        Cancut = X
    else:
        low  = X
# 出力
Cancut = int( 100 * Cancut) / 100
print(math.ceil(Cancut))