Problem: 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.

Submission attempts (in order):
N ,K = map(int, input().split())

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


min1 = 0
max1 = max(A)

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

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


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

import math

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


min = 1
max = max(A)

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


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

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


min = 0
max = max(A)

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


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


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


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

import math

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


min = 1
max = max(A)

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

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

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


min = 1
max = max(A)

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

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


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


Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Accepted