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 math
N,K = map(int,input().split())
a = list(map(int,input().split()))
def is_ok(arg):
    i = 0
    for item in a:
        i += a //arg -1
    return i <=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

Submission status: Wrong Answer

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

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

l = 1
u = max(a)

while u > l+1:
#    print(l,u)
    c = (l + u) // 2
    cnt = 0
    for i in a:
        cnt = cnt + ((i-1+0.01)//c)
    if cnt <= k:
        u = c
    else:
        l = c

print(u)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_right
from math import ceil
N,K=map(int, input().split())
A=list(map(int, input().split()))
if K==0:
    print(max(A))
    exit()

A=sorted(A)
# 最小値で二分探索 してまだ行けるかどうか
# 回数で二分探索
left=0
right=max(A)

ans=float("INF")
pre=ans
flag=False
count=0
while True:
    now=0
    mid=(left+right)/2
    idx=bisect_right(A, mid)
    for i in range(idx, N):
        now+=ceil(A[i]/mid)-1
    if now==K:
        if ans!=float("INF"):
            if ans==ceil(mid):
                flag=True
        ans=min(ans, ceil(mid))
        right=mid
        
        if flag:
            break
        pre=ans
    if now>K:
        left=mid
        pre=mid
    if now<K:
        ans=min(ans, ceil(mid))
        right=mid
        pre=mid
    count+=1
    if count>=5*10**6:
        break
    


if ans==float("INF"):
    ans=max(A)
print(ceil(ans))

Submission status: Wrong Answer

Solution code:
def binary_search2(func, n_min, n_max):
    left,right=n_min,n_max
    y_left, y_right = func(left), func(right)
    while True:
        middle = (left+right)//2
        y_middle = func(middle)
        if y_left==y_middle: left=middle
        else: right=middle
        if right-left==1:break

    return left
  
def f(x):
  return sum([A[i]//x for i in range(N)])<=K

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

print(binary_search2(f, 1, max(A)+5)+1)

Submission status: Wrong Answer

Solution code:
import math

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

def ink(L):
    cnt = 0
    for i in range(N):
        cnt += A[i]//L
    return cnt <= K

bottom, top = 0, max(A)

while(top - bottom > 1):
    middle = (top + bottom) // 2
    if ink(middle): top = middle
    else: bottom = middle

print(top)

Submission status: Wrong Answer

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

def c(x):
    cnt=0
    for i in a:
        cnt += i // x
    return cnt <= k
    
l, r = 0, 10**9
while l + 1 < r:
    mid = (l + r) // 2
    if c(mid):
        r = mid
    else:
        l = mid

print(r)

Submission status: Wrong Answer

Solution code:
def binary_search2(func, n_min, n_max):
    left,right=n_min,n_max
    y_left, y_right = func(left), func(right)
    while True:
        middle = (left+right)//2
        y_middle = func(middle)
        if y_left==y_middle: left=middle
        else: right=middle
        if right-left==1:break

    return left
  
def f(x):
  return sum([A[i]//x for i in range(N)])<=K

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

print(binary_search2(f, 1, max(A))+1)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_right
from math import ceil
N,K=map(int, input().split())
A=list(map(int, input().split()))
if K==0:
    print(max(A))
    exit()

A=sorted(A)
# 最小値で二分探索 してまだ行けるかどうか
# 回数で二分探索
left=0
right=max(A)+1

ans=float("INF")
pre=ans
flag=False
count=0
while True:
    now=0
    mid=(left+right)/2
    idx=bisect_right(A, mid)
    for i in range(idx, N):
        now+=ceil(A[i]/mid)-1
    if now==K:
        if ans!=float("INF"):
            if ans==ceil(mid):
                flag=True
        ans=min(ans, ceil(mid))
        right=mid
        
        if flag:
            break
        pre=ans
    if now>K:
        left=mid
        pre=mid
    if now<K:
        ans=min(ans, ceil(mid))
        right=mid
        pre=mid
    count+=1
    if count>=10**6:
        break


if ans==float("INF"):
    ans=max(A)
print(ceil(ans))

Submission status: Wrong Answer

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

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

l = 1
u = max(a)

while u > l+1:
#    print(l,u)
    c = (l + u) // 2
    cnt = 0
    for i in a:
        cnt = cnt + ((i-1)//c)
    if cnt <= k:
        u = c
    else:
        l = c

print(u)

Submission status: Wrong Answer

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

def c(x):
    cnt=0
    for i in a:
        cnt += i // x
    return cnt <= k
    
l, r = 0, max(a) + 1
while l + 1 < r:
    mid = (l + r) // 2
    if c(mid):
        r = mid
    else:
        l = mid

print(r)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_right
from math import ceil
N,K=map(int, input().split())
A=list(map(int, input().split()))
if K==0:
    print(max(A))
    exit()

A=sorted(A)
# 最小値で二分探索 してまだ行けるかどうか
# 回数で二分探索
left=0
right=max(A)

ans=float("INF")
pre=ans
flag=False
count=0
while True:
    now=0
    mid=(left+right)/2
    idx=bisect_right(A, mid)
    for i in range(idx, N):
        now+=ceil(A[i]/mid)-1
    if now==K:
        if ans!=float("INF"):
            if ans==ceil(mid):
                flag=True
        ans=min(ans, ceil(mid))
        right=mid
        
        if flag:
            break
        pre=ans
    if now>K:
        left=mid
        pre=mid
    if now<K:
        ans=min(ans, ceil(mid))
        right=mid
        pre=mid
    count+=1
    if count>=10**6:
        break


if ans==float("INF"):
    ans=max(A)
print(ceil(ans))

Submission status: Wrong Answer

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

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

l = 1
u = max(a)

while u > l+1:
#    print(l,u)
    c = (l + u) // 2
    cnt = 0
    for i in a:
        cnt = cnt + (i//c)
    if cnt <= k:
        u = c
    else:
        l = c

print(u)

Submission status: Wrong Answer

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

def c(x):
    cnt=0
    for i in a:
        cnt += i // x
    return cnt <= k
    
l, r = 0, max(a)
while l + 1 < r:
    mid = (l + r) // 2
    if c(mid):
        r = mid
    else:
        l = mid
        
print(r)

Submission status: Wrong Answer

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

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

l = 1
u = max(a)

while u != l+1:
#    print(l,u)
    c = (l + u) // 2
    cnt = 0
    for i in a:
        cnt = cnt + (i//c)
    if cnt <= k:
        u = c
    else:
        l = c

print(u)

Submission status: Wrong Answer

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

right=10**9
left=1

while right-left>1 :
    mid=(left+right)//2
    count=0
    for a in A :
        count+=a//mid
        if a%mid==0 :
            count-=1
    if count<=k :
        right=mid
    else :
        left=mid

print(right)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_right
from math import ceil
N,K=map(int, input().split())
A=list(map(int, input().split()))
if K==0:
    print(max(A))
    exit()

A=sorted(A)
# 最小値で二分探索 してまだ行けるかどうか
# 回数で二分探索
left=0
right=max(A)

ans=float("INF")
pre=ans
flag=False
count=0
while True:
    now=0
    mid=(left+right)/2
    idx=bisect_right(A, mid)
    for i in range(idx, N):
        now+=ceil(A[i]/mid)-1
    if now==K:
        if ans!=float("INF"):
            if ceil(ans)==ceil(mid):
                flag=True
        ans=min(ans, mid)
        right=mid
        
        if flag:
            break
        pre=ans
    if now>K:
        left=mid
        pre=mid
    if now<K:
        ans=min(ans, mid)
        right=mid
        pre=mid
    count+=1
    if count>=10**6:
        break


if ans==float("INF"):
    ans=max(A)
print(ceil(ans))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
a = [x * 2 for x in a]
result = max(a)
left = 1
right = result
med = left + (right - left) // 2
while left <= right:
    counter = sum([x // med for x in a])
    if counter <= k:
        result = med
        right = med - 1
    else:
        left = med + 1
    med = left + (right - left) // 2
print((result + 1) // 2)

Submission status: Wrong Answer

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

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

def f(x):
    cnt = 0
    for i in A:
        if i % x == 0:
            cnt += i//x - 1
        else:
            cnt += i//x
    
    if cnt <= K:
        return True
    else:
        return False


ok = 1
ng = 1e10
from math import log2, ceil
A_max = max(A)
while ng - ok > 1:
    mid = (ok + ng) // 2
    if f(mid):
        ng = mid
    else:
        ok = mid
print(ceil(ng))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
result = max(a)
a = [x * 2 for x in a]
left = 1
right = result
med = left + (right - left) // 2
while left <= right:
    counter = sum([x // med for x in a])
    if counter <= k:
        result = med
        right = med - 1
    else:
        left = med + 1
    med = left + (right - left) // 2
print((result + 1) // 2)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
result = max(a)
# a = [x * 2 for x in a]
left = 1
right = result
med = left + (right - left) // 2
while left <= right:
    counter = sum([x // med for x in a])
    if counter <= k:
        result = med
        right = med - 1
    else:
        left = med + 1
    med = left + (right - left) // 2
print(result)

Submission status: Wrong Answer

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

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

def f(x):
    cnt = 0
    for i in A:
        if i % x == 0:
            cnt += i//x - 1
        else:
            cnt += i//x
    
    if cnt <= K:
        return True
    else:
        return False


ok = 1
ng = 1e10
for i in range(60):
    mid = (ok + ng) // 2
    if f(mid):
        ng = mid
    else:
        ok = mid
print(ng)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
tree = list(map(int, input().split()))
left = 0
right = 2*(10**9)
treeLen = len(tree)

if K == 0:
    print(max(tree))
    exit()
while right - left > 1:
    cnt = 0
    mid = (right + left) // 2
    for i in range(treeLen):
        cnt += tree[i] // mid
    if K >= cnt:
        right = mid
    else:
        left = mid

print(right)

Submission status: Wrong Answer

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

maxi = max(an)
if k == 0:
    print(maxi)
    exit(0)


def judge(t):
    m = 0
    for i in an:
        m += i//t+1
    #print('judge', m, n+k)
    if m <= n+k:
        #print("true")
        return True
    else:
        #print("false")
        return False

mini = 0
#maxi = max(an)

while mini+1 != maxi:
    check = (mini+maxi)//2
    #print(check)
    if judge(check):
        maxi = check
        #print(mini, maxi)
    else:
        mini = check
        #print(mini, maxi)

print(maxi)

Submission status: Wrong Answer

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

if k == 0:
    print(max(an))


def judge(t):
    m = 0
    for i in an:
        m += i//t+1
    #print('judge', m, n+k)
    if m <= n+k:
        #print("true")
        return True
    else:
        #print("false")
        return False

mini = 0
maxi = max(an)

while mini+1 != maxi:
    check = (mini+maxi)//2
    #print(check)
    if judge(check):
        maxi = check
        #print(mini, maxi)
    else:
        mini = check
        #print(mini, maxi)

print(maxi)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
tree = list(map(int, input().split()))
left = 0
treeLen = len(tree)
right = max(tree)
while right - left > 1:
    cnt = 0
    mid = (right + left) // 2
    for i in range(treeLen):
        cnt += tree[i] // mid
    if K >= cnt:
        right = mid
    else:
        left = mid
print(right)

Submission status: Wrong Answer

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

def judge(t):
    m = 0
    for i in an:
        m += i//t+1
    #print('judge', m, n+k)
    if m <= n+k:
        #print("true")
        return True
    else:
        #print("false")
        return False

mini = 0
maxi = max(an)

while mini+1 != maxi:
    check = (mini+maxi)//2
    #print(check)
    if judge(check):
        maxi = check
        #print(mini, maxi)
    else:
        mini = check
        #print(mini, maxi)

print(maxi)

Submission status: Wrong Answer

Solution code:
N,K=map(int, input().split())
A=list(map(int, input().split()))
if K==0:
  print(max(A))
  exit()
def f(x):
  cnt=0
  for i in A:
    if i%x==0:
      cnt+=i//x-1
    else:
      cnt+=(i//x)
  if cnt<=K:
    return True
  else:
    return False
ok=1
ng=1000000000
for i in range(50):
  mid=(ok+ng)//2
  if f(mid):
    ng=mid
  else:
    ok=mid
print(ok)

Submission status: Wrong Answer

Solution code:
from math import ceil
class BisectSearch:
    def __init__(self, f, l=0, r=10**9):
        self.f = f
        self.l = l
        self.r = r
    def __call__(self, dist):
        f = self.f
        l = self.l
        r = self.r
        if dist <= f(l):
            return l
        if f(r) <= dist:
            return r
        while r-l > 1:
            n = (r+l) // 2
            if f(n) <= dist:
                l = n
            else:
                r = n
        return l

n, k, *A = map(int, open(0).read().split())
bs = BisectSearch(lambda x:k+1-sum(ceil(a/x)-1 for a in A), l=1, r=10**9+1)
print(bs(0)+1)

Submission status: Wrong Answer

Solution code:
def e_logs():
    N, K = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]

    def ceil_int(p, q):
        """p/q の切り上げ"""
        return (p + q - 1) // q

    def calc(x):
        """K 回以内のカットですべての丸太の長さを x 以下にできるか？"""
        return sum(ceil_int(a, x) - 1 for a in A) <= K

    # 全丸太の長さは、0 以下にはできないし、max(A) には必ずできる (どれも切らない)
    reject, accept = 0, max(A)
    while accept - reject > 2:
        mid = (accept + reject) // 2
        if calc(mid):
            accept = mid
        else:
            reject = mid
    return accept

print(e_logs())

Submission status: Wrong Answer

Solution code:
def main():
    n,k = map(int,input().split())
    a = list(sorted(map(int,input().split())))
    mi = 0
    MA = a[n-1]
    if(k == 0):
        print(MA)
        return
    while(True):
        m = mi + (MA - mi)//2
        if(MA == 1):
            print(1)
            return
        #print(mi,m,MA)
        count = 0
        for i in a:
            plus = i//m - 1 if i%m == 0 else i//m 
            count += plus
        if(MA - mi <= 2):
            if(k > count):
                print(m)
            else:
                print(mi)
            break

        if(k < count):
            mi = m+1
        else:
            MA = m
        




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

N, K = MI()
mylist = LI()
length = len(mylist)

high = max(mylist)+1
low = 0
mid = (high + low) / 2

while high - low >= 0.1:
    temp = 0
    for i in mylist:
        if i % mid == 0:
            temp += (i // mid) - 1
        else:
            temp += i // mid
    if temp >= K:
        low = mid
    else:
        high = mid
    mid = (high + low) / 2

result = math.ceil(low)
print(result)

Submission status: Wrong Answer

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

min_num = 1
max_num = 10**9+1
while True:
    print(min_num)
    x = int((min_num+max_num)/2)
    if sum([math.ceil(a/x)-1 for a in a_list])>k:
        min_num = x
    else:
        max_num = x
    if max_num-min_num<=1:
        break
    #print(x)
if sum([math.ceil(a/min_num)-1 for a in a_list])>k:
    print(min_num+1)
else:
    print(min_num)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
a = list(map(int, input().split()))
max_a = 10**9
min_a = 0

while max_a-min_a>1:
    count = K
    mean_a = (max_a+min_a)//2
    
    for i in range(N):
        if a[i]==mean_a: continue
        count -= -a[i]//mean_a
    if count >= 0:
        max_a = mean_a
    else:
        min_a = mean_a

print(max_a)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
from itertools import accumulate #list(accumulate(A))
import math

N, K = mi()
A = li()

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

left = 0
right = max(A)

def count(num):
    cnt = 0
    for i in range(N):
        cnt += math.ceil(A[i] / num) - 1
    return cnt

while True:
    mid = (left + right) // 2
    if mid == 0:
        print(1)
        exit()
    tmp = count(mid)
    if right - left <= 1:
        mid = right
        break
    elif tmp > K:
        left = mid
    else:
        right = mid

right = mid

while True:
    tmp = count(mid)
    if tmp == K and tmp != count(mid-1):
        print(mid)
        break
    elif tmp == K:
        right = mid
    else:
        if left == mid:
            print(mid+1)
            break
        left = mid
    mid = (left + right) // 2
    if mid == 0:
        print(1)
        break

Submission status: Wrong Answer

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

max_a = 10**9
min_a = 0

while max_a-min_a != 1:
    count = K
    mean_a = (max_a+min_a)//2

    for i in range(N):
        count -= a[i]//mean_a

    if count >= 0:
        max_a = mean_a
    else:
        min_a = mean_a

print(max_a)

Submission status: Wrong Answer

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

min_num = 1
max_num = 10**9+1
while True:
    print(min_num)
    x = int((min_num+max_num)/2)
    if sum([math.ceil(a/x)-1 for a in a_list])>k:
        min_num = x
    else:
        max_num = x
    if max_num-min_num<=1:
        break
    #print(x)
if sum([math.ceil(a/min_num)-1 for a in a_list])>k:
    print(int(min_num)+1)
else:
    print(int(min_num))

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
arr = list(map(int,input().split()))
denominator = sum(arr)

#piece = [K*arr[i]//denominator+1 for i in range(N)]
#value = [arr[i]/piece[i] for i in range(N)]
#print(piece)
import copy
value = copy.deepcopy(arr)
piece = [1 for i in range(N)]
left = K+N-sum(piece)
for i in range(left):
    j = value.index(max(value))
    piece[j] += 1
    value[j] = arr[j]/piece[j]

import math
print(round(max(value) + 0.00005))

Submission status: Wrong Answer

Solution code:
N, M = input().strip().split()
n, k = [int(N), int(M)]
a = list(map(int, input().strip().split()))
le = 0
ri = 10000000000
while ri - le > 1:
    mid = (le + ri) 
    num = 0
    for i in a:
        num += (i-1) 
    if num <= k:
        ri = mid
    else:
        le = mid
print(ri)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
from itertools import accumulate #list(accumulate(A))
import math

N, K = mi()
A = li()

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

left = 0
right = max(A)

def count(num):
    cnt = 0
    for i in range(N):
        cnt += math.ceil(A[i] / num) - 1
    return cnt

while True:
    mid = (left + right) // 2
    if mid == 0:
        mid += 1
        break
    tmp = count(mid)
    if tmp == K:
        break
    elif tmp > K:
        if left == mid:
            mid += 1
            break
        left = mid
    else:
        right = mid

if mid == 0 or mid == 1:
    print(mid)
    exit()

if count(mid) != K:
    print('Yeah')
    exit()
right = mid

while True:
    tmp = count(mid)
    if tmp == K and tmp != count(mid-1):
        print(mid)
        break
    elif tmp == K:
        right = mid
    else:
        #if left == mid:
            #print(mid+1)
            #break
        left = mid
    mid = (left + right) // 2
    if mid == 0:
        print(1)
        break

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
arr = list(map(int,input().split()))
denominator = sum(arr)

#piece = [K*arr[i]//denominator+1 for i in range(N)]
#value = [arr[i]/piece[i] for i in range(N)]
#print(piece)
import copy
value = copy.deepcopy(arr)
piece = [1 for i in range(N)]
left = K+N-sum(piece)
for i in range(left):
    j = value.index(max(value))
    piece[j] += 1
    value[j] = arr[j]/piece[j]

import math
print(round(max(value) + 0.0000001))

Submission status: Wrong Answer

Solution code:
def main():
    n,k = map(int,input().split())
    a = list(sorted(map(int,input().split())))
    mi = 0
    MA = a[n-1]
    if(k == 0):
        print(MA)
        return
    while(True):
        m = mi + (MA - mi)//2
        if(MA == 1):
            print(1)
            return
        #print(mi,m,MA)
        count = 0
        for i in a:
            count += i//m
        #print(mi,m,MA)
        if(MA - mi <= 2):
            if(k >= count):
                print(m)
            else:
                print(mi)
            break

        if(k <= count):
            mi = m+1
        else:
            MA = m-1
        




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
arr = list(map(int,input().split()))
denominator = sum(arr)

import copy
value = copy.deepcopy(arr)
piece = [1 for i in range(N)]
left = K+N-sum(piece)
for i in range(left):
    j = value.index(max(value))
    piece[j] += 1
    value[j] = arr[j]/piece[j]

import math
print(round(round(max(value)*10)/10))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
from itertools import accumulate #list(accumulate(A))
import math

N, K = mi()
A = li()

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

left = 0
right = max(A)

def count(num):
    cnt = 0
    for i in range(N):
        cnt += math.ceil(A[i] / num) - 1
    return cnt

while True:
    mid = (left + right) // 2
    if mid == 0:
        mid += 1
        break
    tmp = count(mid)
    if tmp == K:
        break
    elif tmp > K:
        if left == mid:
            mid += 1
            break
        left = mid
    else:
        right = mid

if mid == 0 or mid == 1:
    print(mid)
    exit()


right = mid

while True:
    tmp = count(mid)
    if tmp == K and tmp != count(mid-1):
        print(mid)
        break
    elif tmp == K:
        right = mid
    else:
        if left == mid:
            print(mid+1)
            break
        left = mid
    mid = (left + right) // 2
    if mid == 0:
        print(1)
        exit()

Submission status: Wrong Answer

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

min_num = 1
max_num = 10**9+1
while True:
    x = int((min_num+max_num)/2)
    if sum([math.ceil(a/x)-1 for a in a_list])>k:
        min_num = x
    else:
        max_num = x
    if max_num-min_num<=1:
        break
    #print(x)
print(int(max_num))

Submission status: Wrong Answer

Solution code:
from math import ceil


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    ok = 0
    ng = 10 ** 9 + 7
    while abs(ok - ng) > 0.5:
        mid = (ok + ng) / 2
        cnt = 0
        for i in range(n):
            cnt += ceil(a[i] / mid) - 1
        if k < cnt:
            ok = mid
        else:
            ng = mid
    print(ceil(ok))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

l = 1
r = max(arr)

while l + 1 < r:
    m = (l + r) // 2

    cut = 0
    for x in arr:
        cut += (x - 1) // m

    if cut > k:
        l = m
    else:
        r = m

print(r)

Submission status: Wrong Answer

Solution code:
def main():
    n,k = map(int,input().split())
    a = list(sorted(map(int,input().split())))
    mi = 0
    MA = a[n-1]
    ans = -1
    if(k == 0):
        print(MA)
        return
    while(True):
        m = mi + (MA - mi)//2
        if(MA == 1):
            print(1)
            return
        #print(mi,m,MA)
        count = 0
        for i in a:
            count += i//m

        if(MA <= mi):
            print(ans)
            break

        if(k <= count):
            ans = m
            mi = m+1
        else:
            MA = m-1
        




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n,k = map(int,input().split())
    a = list(sorted(map(int,input().split())))
    mi = 0
    MA = a[n-1]
    ans = -1
    if(k == 0):
        print(MA)
        return
    while(True):
        m = mi + (MA - mi)//2
        print(mi,m,MA,ans)
        if(MA == 1):
            print(1)
            return
        #print(mi,m,MA)
        count = 0
        for i in a:
            count += i//m

        if(MA <= mi):
            print(ans)
            break

        if(k <= count):
            ans = m
            mi = m+1
        else:
            MA = m-1
        




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n,k = map(int,input().split())
    a = list(sorted(map(int,input().split())))
    mi = 0
    MA = a[n-1]
    ans = -1
    if(k == 0):
        print(MA)
        return
    while(True):
        m = mi + (MA - mi)//2
        if(MA == 1):
            print(1)
            return
        #print(mi,m,MA)
        count = 0
        for i in a:
            count += i//m
        if(MA <= mi):
            print(ans)
            break
        if(k <= count):
            ans = m
            mi = m+1
        else:
            MA = m-1
        




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n,k = map(int,input().split())
    a = list(sorted(map(int,input().split())))
    mi = 0
    MA = a[n-1]
    ans = -1
    if(k == 0):
        print(MA)
        return
    while(True):
        m = mi + (MA - mi)//2
        if(MA == 1):
            print(1)
            return
        #print(mi,m,MA)
        count = 0
        for i in a:
            count += i//m
        if(MA < mi):
            print(ans)
            break
        if(k == count):
            ans = m
        if(k < count):
            mi = m+1
        else:
            MA = m-1
        




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n,k = map(int,input().split())
    a = list(sorted(map(int,input().split())))
    mi = 0
    MA = a[n-1]
    ans = -1
    if(k == 0):
        print(MA)
        return
    while(True):
        m = mi + (MA - mi)//2
        if(MA == 1):
            print(1)
            return
        #print(mi,m,MA)
        count = 0
        for i in a:
            count += i//m
        if(MA < mi):
            print(ans)
            break
        if(k == count):
            ans = m
            MA = m-1
        elif(k < count):
            mi = m+1
        else:
            MA = m-1
        




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys

n, k, *aaa = map(int, sys.stdin.buffer.read().split())
l = 1
r = max(aaa)
while l + 1 < r:
    m = (l + r) // 2
    if sum((a - 1) // m for a in aaa) > k:
        l = m
    else:
        r = m

print(r)

Submission status: Wrong Answer

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

l = 1
r = 10**9 + 1

import math
while l < r:
    mid = (l + r) // 2
    counter = 0
    for i in range(N):
        if A[i] > mid:
            counter += math.ceil(A[i]/mid) - 1
    if counter <= K:
        r = mid - 1
    else:
        l = mid

print(l)

Submission status: Wrong Answer

Solution code:
def main():
    n,k = map(int,input().split())
    a = list(sorted(map(int,input().split())))
    mi = 0
    MA = a[n-1]
    if(k == 0):
        print(MA)
        return
    while(True):
        m = mi + (MA - mi)//2
        if(MA == 1):
            print(1)
            return
        #print(mi,m,MA)
        count = 0
        for i in a:
            count += i//m
        if(MA < mi):
            print(mi)
            break
        if(k < count):
            mi = m+1
        else:
            MA = m-1
        




if __name__ == "__main__":
    main()