Problem p02598 (python)

Fixed submission:
N, K = map(int, input().split())
A=list(map(int,input().split()))
A.sort()
right = A[-1]+1
left = 0
flag = True
mid = (left+right)//2
minN = right
result = mid
while right-left>1 and flag:
    mid = (left+right)//2
    count = 0
    for i in A:
        count += (i-1)//mid
    if count <= K:
        right = mid
        if minN>mid:
            minN = mid
            result = mid
    elif count > K:
        left = mid
print(result)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A=list(map(int,input().split()))
A.sort()
right = A[-1]+1
left = -1
flag = True
mid = (left+right)//2
minN = right
result = mid
while right-left>1 and flag:
    mid = (left+right)//2
    count = 0
    for i in A:
        count += (i-1)//mid
    if count <= K:
        right = mid
        if minN>mid:
            minN = mid
            result = mid
    elif count > K:
        left = mid
print(result)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A=list(map(int,input().split()))
A.sort()
right = A[-1]+1
left = -1
flag = True
mid = (left+right)//2
minN = right
result = right
while right-left>1 and flag:
    mid = (left+right)//2
    count = 0
    for i in A:
        count += (i-1)//mid
    if count <= K:
        right = mid
        if minN>mid:
            minN = mid
            result = mid
    elif count > K:
        left = mid
print(result)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A=list(map(int,input().split()))
A.sort()
right = A[-1]+1
left = -1
flag = True
mid = (left+right)//2
minN = right
while right-left>1 and flag:
    mid = (left+right)//2
    count = 0
    for i in A:
        count += (i-1)//mid
    if count <= K:
        right = mid
        if minN>mid:
            minN = mid
            result = mid
    elif count > K:
        left = mid
print(result)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A=list(map(int,input().split()))
A.sort()
right = A[-1]+1
left = -1
flag = True
mid = (left+right)//2
while right-left>1 and flag:
    mid = (left+right)//2
    count = 0
    for i in A:
        count += (i-1)//mid
    if count <= K:
        right = mid
    elif count > K:
        left = mid
    else:
        flag = False
print(mid)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A=list(map(int,input().split()))
A.sort()
right = A[-1]+1
left = -1
flag = True
while right-left>1 and flag:
    mid = (left+right)//2
    count = 0
    for i in A:
        count += (i-1)//mid
    if count <= K:
        right = mid
    elif count > K:
        left = mid
    else:
        flag = False
print(mid)

Buggy submission (verdict: Runtime Error):
import math
N, K = map(int, input().split())
A=list(map(int,input().split()))
maxA = max(A)
right = maxA
left = 0
while(right-left>1):
    mid = (left+right)//2
    count = 0
    for i in A:
        count += (i-1)//mid
    if count > K:
        left = mid
    elif count <= K:
        right = mid
print(mid)

Buggy submission (verdict: Runtime Error):
import math
N, K = map(int, input().split())
A=list(map(int,input().split()))
maxA = max(A)
num = 0
right = maxA
left = 0
while(right-left>1):
    num = left+math.floor((right-left)*0.5)
    count = 0
    for i in range(len(A)):
        count += math.ceil(A[i]/num)-1
    if count > K:
        left = num
    elif count <= K:
        right = num
count = 0
num = right
for i in range(len(A)):
    count += math.ceil(A[i]/num)-1
if count!=K:
    num = left
    count = 0
    for i in range(len(A)):
        count += math.ceil(A[i]/num)-1
print(num)

Buggy submission (verdict: Runtime Error):
import math
N, K = map(int, input().split())
A=list(map(int,input().split()))
maxA = max(A)
num = 0
right = maxA
left = 0
while(right-left>1):
    num = left+math.floor((right-left)*0.5)
    count = 0
    for i in range(len(A)):
        count += math.ceil(A[i]/num)-1
    if count > K:
        left = num
    elif count < K:
        right = num
count = 0
num = right
for i in range(len(A)):
    count += math.ceil(A[i]/num)-1
if count!=K:
    num = left
    count = 0
    for i in range(len(A)):
        count += math.ceil(A[i]/num)-1
print(num)

Buggy submission (verdict: Runtime Error):
import math
N, K = map(int, input().split())
A=list(map(int,input().split()))
maxA = max(A)
flag = True
num = 0
right = maxA
left = 0
while(flag):
    num = left+math.floor((right-left)*0.5)
    count = 0
    ##print()
    ##print(num)
    for i in range(len(A)):
        count += math.ceil(A[i]/num)-1
        ##print(math.ceil(A[i]/num)-1)
    if count > K:
        if right-num>1:
            left = num
        elif right-num==1:
            num = right
            flag = False
    elif count < K:
        if num-left>1:
            right = num
        elif num-left==1:
            num = left
            flag = False
    else:
        flag = False

print(num)