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:
#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.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 = int( 10 * Cancut) / 10
print(math.ceil(Cancut))

Submission status: Wrong Answer

Solution code:
import math

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

def binary_search(ng=1, ok=max(a)):
    if ok - ng < 2: return ok
    mid = (ok + ng) // 2
    cnt = 0
    for i in a:
        cnt += math.ceil(i / mid) - 1
    if cnt <= k:
        return binary_search(ng, mid)
    else:
        return binary_search(mid, ok)
print(binary_search())

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
X = max(A)
if K == 0:
    print(X)
    exit()
else:
    for i in range(1, math.ceil(math.log2(X)) + 1):
        B = []
        for a in A:
            b = math.ceil(a / X) - 1
            B.append(b)
        B_total = sum(B)
        if B_total > K:
            X += max(A) / pow(2, i)
        else:
            X -= max(A) / pow(2, i)
    print(math.ceil(X))

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 ( abs(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
# 出力
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
        Cancut = X
        if abs(high - low) <= 0.01 : break
    else:
        low  = X
# 出力
print(math.ceil(Cancut))

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
X = max(A)
if K == 0:
    print(X)
    exit()
else:
    for i in range(1, 32):
        B = []
        for a in A:
            b = math.ceil(a / X) - 1
            B.append(b)
        B_total = sum(B)
        if B_total > K:
            X += max(A) / pow(2, i)
        else:
            X -= max(A) / pow(2, i)
    print(math.ceil(X))

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
X = max(A)
if K == 0:
    print(X)
    exit()
else:
    for i in range(1, 32):
        B = []
        for a in A:
            b = math.ceil(a / X) - 1
            B.append(b)
        B_total = sum(B)
        if B_total > K:
            X += int(max(A) / pow(2, i))
        else:
            X -= int(max(A) / pow(2, i))
    print(X)

Submission status: Wrong Answer

Solution code:
ma = lambda :map(int,input().split())
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
n,k = ma()
A = list(ma())
A.sort(reverse=True)
if k==0:
    print(A[0])
    exit()

def isok(x):
    cnt=0
    for a in A:
        cnt+= (a-1)//x
    #print(cnt,x)
    return cnt>k
def bisect():
    ok = 1
    ng = 10**9+1
    x = (ok+ng)//2
    while ng-ok>1:
        if isok(x):
            ok = x
        else:
            ng=x
        x = (ok+ng)//2
    return ng
print(bisect())

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.1
        Cancut = X
    else:
        low  = X + 0.1
# 出力
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):
        if math.floor(A[i] / X) > 0:
            Cut = Cut + math.ceil(A[i]/X) - 1
    if Cut <= K:
        high = X - 0.1
        Cancut = X
    else:
        low  = X + 0.1
# 出力
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  = 1
while ( low < high ) :
    Cut = 0
    X = (high + low) / 2
    for i in range(N):
        Cut = Cut + math.ceil(A[i]/X) - 1
    if Cut <= K:
        high = X - 0.1
        Cancut = X
    else:
        low  = X + 0.1
# 出力
print(math.ceil(Cancut))

Submission status: Wrong Answer

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

def queri(n):
    count = 0
    for i in A:
        count += -(-i//n)
    if k>= count:
        return True
    else:
        return False

while ok - ng > 1:
    mid = (ok+ng)//2
    if queri(mid) :
        ok = mid
    else:
        ng = mid
print(ok)

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()
    A = LI()

    # 最大の長さがxになるような切断回数
    def cut_num(x):
        ret = sum([math.ceil(i / x) - 1 for i in A])
        return ret

    ng = 0
    ok = max(A)
    while abs(ok-ng)>10**(-5):
        m = (ng+ok)/2
        if cut_num(m) <= K:
            ok = m
        else:
            ng = m

    print(math.ceil(ok))

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()
    A = LI()

    # 最大の長さがxになるような切断回数
    def cut_num(x):
        ret = sum([math.ceil(i / x) - 1 for i in A])
        return ret

    ng = 0
    ok = max(A)
    while abs(ok-ng)>10**(-4):
        m = (ng+ok)/2
        if cut_num(m) <= K:
            ok = m
        else:
            ng = m

    print(math.ceil(ok))

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()
    A = LI()

    # 最大の長さがxになるような切断回数
    def cut_num(x):
        ret = sum([math.ceil(i / x) - 1 for i in A])
        return ret

    ng = 0
    ok = max(A)
    while abs(ok-ng)>10**(-3):
        m = (ng+ok)/2
        if cut_num(m) <= K:
            ok = m
        else:
            ng = m

    print(math.ceil(ok))

if __name__ == '__main__':
    resolve()

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
    for i in range(N):
        Cut = Cut + math.ceil(A[i]/X) - 1
    if Cut <= K:
        high = X - 0.0001
        Cancut = X
    else:
        low  = X + 0.0001
# 出力
print(math.ceil(Cancut))

Submission status: Wrong Answer

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

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

def cal(x):
    s = 0
    for aa in a:
        s += math.ceil(aa/x) - 1
    if s <= K: return True
    else: return False

l = 1
r = max(a)
while abs(r - l) > 1:
    mid = (l + r) // 2
    if cal(mid):
        r = mid
    else:
        l = mid
print(r)

Submission status: Wrong Answer

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

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

def cal(x):
    s = 0
    for aa in a:
        s += math.ceil(aa/x) - 1
    if s <= K: return True
    else: return False

l = 1
r = max(a)
while (r - l) > 1:
    mid = (l + r) // 2
    if cal(mid):
        r = mid
    else:
        l = mid
print(r)

Submission status: Wrong Answer

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

ok=max(alst)
ng=0

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

    cnt=0

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

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

if ok%10==0:
    print(ok//10)
else:
    print(ok//10+1)

Submission status: Wrong Answer

Solution code:
from math import floor, ceil

n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
l = 1
r = max(a)
while r - l > 1:
    c = (l+r)//2
    cnt = 0
    for i in a:
        cnt += max(ceil(i/c) - 1, 0)
    if cnt <= k:
        r = c
    else:
        l = c
print(r)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(l)

Submission status: Wrong Answer

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

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

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

main()

Submission status: Wrong Answer

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

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

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

    print(ok + 1)


solve()

Submission status: Wrong Answer

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

low = 0
high = 10**9

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

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

Submission status: Wrong Answer

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

low = 1
high = 10**9

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

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

Submission status: Wrong Answer

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

low = 1
high = 10**9

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

Submission status: Wrong Answer

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

low = 1
high = 10**9

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

Submission status: Wrong Answer

Solution code:
import math

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

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

A.sort(reverse = True)

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

Submission status: 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
    for i in range(N):
        Cut = Cut + math.ceil(A[i]/X) - 1
    if Cut <= K:
        high = X - 0.001
        Cancut = X
    else:
        low  = X + 0.001
# 出力
print(math.ceil(Cancut))

Submission status: Wrong Answer

Solution code:
import math
def getc(A,L):
    count = 0
    for i in A:
        cc=math.ceil(i/L)-1

        count += cc
    return count
def resolve():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    A.sort(reverse=True)
    l = 1
    r = max(A)
    if K == 0:
        print(r)
        return
    while l < r-1:
        center = (l+r)//2
        cc=getc(A,center)
        if cc > K:
            l = center
        else:
            r = center
    print(r)
resolve()

Submission status: Wrong Answer

Solution code:
import math
def getc(A,L):
    count = 0
    for i in A:
        cc=math.ceil(i/L)-1
        if  cc <=0:           
            break
        count += cc
    return count
def resolve():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    A.sort(reverse=True)
    l = 1
    r = max(A)
    if K == 0:
        print(r)
        return
    while l < r-1:
        center = (l+r)//2
        cc=getc(A,center)
        if cc > K:
            l = center
        else:
            r = center
    print(r)
resolve()

Submission status: Wrong Answer

Solution code:
import math
def getc(A,L):
    count = 0
    for i in A:
        cc=math.ceil(i/L)-1
        if  cc <=0:           
            break
        count += cc
    return count
 
                
    
 
 
 
 
 
def resolve():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    A.sort(reverse=True)
    l = 1
    r = max(A)
    if K == 0:
        print(r)
        return
    while l < r-1:
        center = (l+r)//2
        cc=getc(A,center)
        if cc > K:
            l = center
        else:
            r = center
    print(r)
resolve()

Submission status: Wrong Answer

Solution code:
import math

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

m = 0
M = max(A)

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

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

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

print(math.ceil(mid))

Submission status: Wrong Answer

Solution code:
import math

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

m = 0
M = max(A)

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

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

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

print(math.ceil(mid))

Submission status: Wrong Answer

Solution code:
import math

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

m = 0
M = max(A)

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

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

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

print(math.ceil(mid))

Submission status: Wrong Answer

Solution code:
import math

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

m = 0
M = max(A)

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

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

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

print(math.ceil(mid))

Submission status: Wrong Answer

Solution code:
import math

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

m = 0
M = max(A)

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

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

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

print(math.ceil(mid))

Submission status: Wrong Answer

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

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

while 1:
    
    m = (l+r)//2
    if m==0:
        break

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

        
print(m)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

        
print(m)

Submission status: Wrong Answer

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

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

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

        
print(m)

Submission status: Wrong Answer

Solution code:

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

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

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

        
print(m)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
import math
x=0
y=10**9
z=5*(10**8)
s=0
for i in range(100):
    t=0
    for j in range(n):
        t+=a[j]//z
    if t<=k:
        s=t
        y=z
        z=(x+y)/2
    else:
        x=z
        z=(x+y)/2
    print(x,y,z)
print(math.ceil(z))

Submission status: Wrong Answer

Solution code:
from math import *

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

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

low = 0
high = 1000000000
ans  =-1

while low <= high:
	mid = (low + high)/2
	cut = trycut(mid)
	# ~ print("low=",low, "high=", high,"val = ",mid,"ret = ",cut)
	if cut <= k:
		high = mid-0.01
		ans = mid
	else:
		low =  mid+0.01
	# ~ if low < high: print(low, high, "je reviens")
ans = int(ans*10)/10
# ~ print(ans)
print(int(ceil(ans)))

Submission status: Wrong Answer

Solution code:
from math import ceil


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

    def check(Min):
        kill = 0
        for a in A:
            kill += (a-1)//Min
        return kill <= K

    l = 1
    r = 1000000000

    while r-l > 1:
        mid = (l+r)//2
        if check(mid):
            r = mid
        else:
            l = mid
    print(r)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import ceil


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

    def check(Min):
        kill = 0
        for a in A:
            kill += (ceil(a/Min)-1)
        return kill <= K

    l = 1
    r = 1000000000

    while r-l > 1:
        mid = (l+r)//2
        if check(mid):
            r = mid
        else:
            l = mid
    print(r)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import *

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

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

low = 0
high = 1000000000
ans  =-1

while low <= high:
	mid = (low + high)/2
	cut = trycut(mid)
	# ~ print("low=",low, "high=", high,"val = ",mid,"ret = ",cut)
	if cut <= k:
		high = mid-0.0000001
		ans = mid
	else:
		low =  mid+0.0000001
	# ~ if low < high: print(low, high, "je reviens")
print(round(ans))

Submission status: Wrong Answer

Solution code:
from math import ceil

def check(arr,n,k,w):
    res=0
    for i in range(n):
        res+=ceil(arr[i]/w)-1
    if res<=k:
        return 1
    return 0
    
n,k=map(int,input().split())
arr=list(map(int,input().split()))

minn=1
maxx=max(arr)
while(1):
    val=(minn+maxx)//2+1
    if maxx==val:
        if check(arr,n,k,val) and not(check(arr,n,k,val-1)):
            print(val)
            break
        else:
            print(val-1)
            break
    if check(arr,n,k,val):
        maxx=val
    else:
        minn=val

Submission status: Wrong Answer

Solution code:
def check(List,mid):
    tmp=0
    for l in List:
        tmp+=(-(-l//mid)-1)
    return tmp

n,k=map(int,input().split())
a=list(map(int,input().split()))
lo=1
hi=max(a)
while hi - lo > 1:
    mid=(lo+hi)//2
    if check(a,mid)<=k:
        hi=mid
    else:
        lo=mid
print(hi)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
log = list(map(int,input().split()))
for i in range(k):
  m = max(log)
  log.remove(m)
  log += [m/2]*2
      
print(round(max(log)))

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
log = list(map(int,input().split()))
for i in range(k):
  m = max(log)
  log.remove(m)
  log += [m/2]*2
  
print(max(log))

Submission status: Wrong Answer

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

def isfeasible(L):
  k = 0
  for i in range(N):
    a = A[i]
    if a < L:
      break
    if a%L == 0:
      dk = a//L - 1
    else:
      dk = a//L
    k += dk
    if k > K:
      return False
  return True

l = 0
r = A[0]
if K == 0:
  print(A[0])
else:
  while r-l>1:
    L = (r+l)//2
    if isfeasible(L):
      r = L
    else:
      l = L+1
  print(r)

Submission status: Wrong Answer

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

def A(x):
    cnt = 0
    for i in range(n):
        cnt +=L[i]//x
    return cnt <= k

lower = 0
upper = max(L)

while upper - lower > 1:
    mid = (lower + upper)//2
    if A(mid):
        upper = mid
    else:
        lower = mid

print(upper)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N, K = MI()
    A = LI()
    A.sort()
    # print(A)
    
    l = 0
    r = max(A)+1
    while l != r-1:
        x = (l + r) // 2
        cnt = 0
        for a in A:
            cnt += ceil(a / x) - 1
        if cnt > K:
            l = x
        else:
            r = x
        # print(x, cnt, l, r)
    print(x)

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
from math import ceil
n, k = map(int, input().split())
a = list(map(int, input().split()))
mi = 0
ma = max(a)
m = ma/2
while ma-mi>0.1:
  temp = 0
  for i in range(n):
    temp += ceil(a[i]/m)-1 
    #if a[i]%m==0:
    #  temp-=1
  if temp<=k:
    ma=m
    m=(ma+mi)/2
  else:
    mi = m
    m=(ma+mi)/2
  #print("temp " + str(temp))
  #print("ma " + str(ma)+ " mi " + str(mi) + " m " + str(m))
#print(m)
print(ceil(m))

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, raw_input().split())
logs = map(int, raw_input().split())

logs.sort()

if(k == 0):
    print logs[-1]
    exit(0)

l = 0
r = logs[-1]


def check(v):
    c = k
    for i in xrange(n-1, -1, -1):
        p = math.ceil(logs[i]/v)
        # print 's', p, c, logs[i]
        if(p-1 <= c):
            c -= p-1
        else:
            return 0
    return 1


ans = logs[-1]
while abs(l-r) > 10**(-5):
    mid = (l+r)/2.0
    # print 'l', l, mid, r, l < r
    # print 'c', check(mid)
    if(check(mid)):
        ans = min(ans, mid)
        r = mid
    else:
        l = mid
print int(round(ans))

Submission status: Wrong Answer

Solution code:
from math import ceil

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


def is_ok(num):
  t = 0
  for log in logs:
    if log <= num:
      continue
    t += ceil(log / n) - 1
  return t <= k

ng = 0
ok = 10 ** 9

while ok - ng > 1 :
  m = (ok + ng) // 2
  
  if is_ok(m):
    ok = m
  else:
    ng = m

print(ceil(ok))

Submission status: Wrong Answer

Solution code:
from math import ceil

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


def is_ok(num):
  t = 0
  for log in logs:
    if log <= num:
      continue
    t += ceil(log / n) - 1
  return t <= k

ng = 0
ok = 10 ** 9

while ok - ng > 1 :
  m = (ok + ng) // 2
  
  if is_ok(m):
    ok = m
  else:
    ng = m

print(ok)