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:
n,k = map(int,input().split())
l = list(map(int,input().split()))

# xは求める長さ
def C(x):
    num = 0
    for i in range(n):
        # int(l/x) 回切る必要がある
        num += int(l[i] / x)
    # k回以内に収まるか
    return num <= k

lb,ub = 0,max(l)
for i in range(200):
    mid = (lb + ub) / 2
    # 条件を満たすならxを小さくしていく
    if C(mid):
        ub = mid
    else:
        lb = mid
    # print(lb,ub)

import math
ans = math.ceil(ub)
print(ans)

Submission status: Wrong Answer

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

# xは求める長さ
def C(x):
    num = 0
    for i in range(n):
        # int(l/x) 回切る必要がある
        num += int(l[i] / x)
    # k回以内に収まるか
    return num <= k

lb,ub = 0,max(l)
for i in range(200):
    mid = (lb + ub) / 2
    # 条件を満たすならxを小さくしていく
    if C(mid):
        ub = mid
    else:
        lb = mid
    print(lb,ub)

import math
ans = math.ceil(ub)
print(ans)

Submission status: Wrong Answer

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

# xは求める長さ
def C(x):
    num = 0
    for i in range(n):
        # int(l/x) 回切る必要がある
        num += int(l[i] / x)
    # k回以内に収まるか
    return num <= k

lb,ub = 0,max(l)
for i in range(100):
    mid = (lb + ub) / 2
    # 条件を満たすならxを小さくしていく
    if C(mid):
        ub = mid
    else:
        lb = mid
    # print(lb,ub)

import math
ans = math.ceil(ub)
print(ans)

Submission status: Wrong Answer

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

def judge(ans,K,A):
    cut=0
    for i in range(len(A)):
        cut+=int(A[i]/int(ans+1))
    if cut>K:
        return False
    else:
        return True


ansp=max(A)
ansm=min(A)
ans=int((ansp+ansm)/2+1)
while True:
    
    if judge(ans,K,A):
        ansp1=((ansp+ans)/2)
        if ansp1==ansp:
            break
        else:
            ansp=ansp1
    else:
        ansm1=((ans+ansm)/2)
        if ansm1==ansm:
            break
        else:
            ansm=ansm1
    ans=(ansp+ansm)/2
if ans-int(ans)<0.00000001:
    print(int(ans))
else:
    print(int(ans)+1)

Submission status: Wrong Answer

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

def judge(ans,K,A):
    cut=0
    for i in range(len(A)):
        cut+=int(A[i]/int(ans+1))
    if cut>K:
        return False
    else:
        return True

ansp=10**9
ansm=1
ans=int((ansp+ansm)/2+1)
while ansp-ansm>0.01:
    
    if judge(ans,K,A):
        ansp=((ansp+ans)/2)
        
    else:
        ansm=((ans+ansm)/2)
    ans=(ansp+ansm)/2
        
print(int(ans)+1)

Submission status: Wrong Answer

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

def judge(ans,K,A):
    cut=0
    for i in range(len(A)):
        cut+=int(A[i]/ans)
    if cut>K:
        return False
    else:
        return True

ansp=10**9
ansm=1

while ansp-ansm>0.01:
    ans=((ansp+ansm)/2)
    if judge(int(ans)+1,K,A):
        ansp=((ansp+ans)/2)
        
    else:
        ansm=((ans+ansm)/2)
        
print(int(ans)+1)

Submission status: Wrong Answer

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

def judge(ans,K,A):
    cut=0
    for i in range(len(A)):
        cut+=int(A[i]/ans)
    if cut>K:
        return False
    else:
        return True

ansp=10**9
ansm=1

while ansp-ansm>0.01:
    ans=((ansp+ansm)/2)
    if judge(ans,K,A):
        ansp=((ansp+ans)/2)
        
    else:
        ansm=((ans+ansm)/2)
        
print(int(ans)+1)

Submission status: Wrong Answer

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

def judge(ans,K,A):
    cut=0
    for i in range(len(A)):
        cut+=int(A[i]/ans)
    if cut>K:
        return False
    else:
        return True

ansp=10**9
ansm=1

while ansp-ansm>0.00001:
    ans=((ansp+ansm)/2)
    if judge(ans,K,A):
        ansp=((ansp+ans)/2)
        
    else:
        ansm=((ans+ansm)/2)
        
print(int(ans)+1)

Submission status: Wrong Answer

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

def judge(ans,K,A):
    cut=0
    for i in range(len(A)):
        cut+=int(A[i]/ans)
    if cut>K:
        return False
    else:
        return True

ansp=10**9
ansm=1

while True:
    ans=int((ansp+ansm)/2)
    if judge(ans,K,A):
        ansp1=int((ansp+ans)/2)
        if ansp==ansp1:
            break
        else:
            ansp=ansp1
    else:
        ansm1=int((ans+ansm)/2)
        if ansm==ansm1:
            break
        else:
            ansm=ansm1
print(ans+1)

Submission status: Wrong Answer

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


def can(x, K):
    ct = 0
    for i in range(N):
        ct += (A[i]-1)//x
    if ct <= K:
        return True
    else:
        return False


while U-L > 1:
    x = (U+L)//2
    if can(x, K):
        U = x
    else:
        L = x

print(U)

Submission status: Wrong Answer

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

s = (10**9) // 2
step = s
best= 999999999999
import math

for j in range(50):
  c = 0
  arr = list(f)
 # print(s)
  
  for i in range(n):
    if arr[i] > s:
      if arr[i] % s != 0:
      	c += arr[i] // s
      else:
        c += arr[i] // s
        c -= 1
      cor = 0
      if arr[i] % (c+1) != 0:
        cor = 1
      arr[i] = arr[i]//(c+1) + cor
    
  step = step//2
  step = max(1, step)
 
  if c<=k:
    best = min(best,max(arr))
   # print(s,best)
    s -= step
  else:
    s += step
    
  if s==0:
    s=1
      
print(best)

Submission status: Wrong Answer

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

s = (10**9) // 2
step = s
best= 999999999999
import math

for j in range(50):
  c = 0
  arr = list(f)
  for i in range(n):
    if arr[i] > s:
      c += arr[i] // s
      cor = 0
      if arr[i] % (c+1) != 0:
        cor = 1
      arr[i] = arr[i]//(c+1) + cor
    
  step = step//2
  step = max(1, step)
 
  if c<=k:
    s -= step
    best = min(best,max(arr))
  else:
    s += step
    
  if s==0:
    s=1
      
print(best)

Submission status: Wrong Answer

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

s = (10**9) // 2
step = s
best= 999999999999
import math

for j in range(50):
  c = 0
  arr = list(f)
  for i in range(n):
    c += arr[i] // s
    cor = 0
    if arr[i] % (c+1) != 0:
      cor = 1
    arr[i] = arr[i]//(c+1) + cor
    
  step = step//2
  step = max(1, step)
 
  if c<=k:
    s -= step
    best = min(best,max(arr))
  else:
    s += step
    
  if s==0:
    s=1
      
print(best)

Submission status: Wrong Answer

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

s = (10**9) // 2
step = s
best= 999999999999
import math

for j in range(50):
  c = 0
  arr = list(f)
  for i in range(n):
    c += arr[i] // s
    arr[i] /= (c+1)
    
  step = step//2
  step = max(1, step)
 
  if c<=k:
    s -= step
    best = min(best,math.ceil(max(arr)))
  else:
    s += step
    
  if s==0:
    s=1
      
print(best)

Submission status: Wrong Answer

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

s = (10**9) // 2
step = s
best= 999999999999
import math

for j in range(40):
  c = 0
  arr = list(f)
  for i in range(n):
    c += arr[i] // s
    arr[i] /= (c+1)
    
  step = step//2
  step = max(1, step)
 
  if c<=k:
    s -= step
    best = min(best,math.ceil(max(arr)))
  else:
    s += step
      
print(best)

Submission status: Wrong Answer

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

def isOK(x):
    cnt = 0
    for a in A:
        cnt += (a + x - 1) // x - 1
    return cnt <= K

left, right = 1, 10 ** 18
while right - left > 1:
    mid = (left + right) // 2
    if isOK(mid):
        left = mid
    else:
        right = mid
print(left)

Submission status: Wrong Answer

Solution code:
def is_ok(X):
    cnt = 0
    for a in A:
        cnt += a//X-1
    if cnt <= k:
        return True
    else:
        return False


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

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

print(meguru_bisect(0,max(A)+1))

Submission status: Wrong Answer

Solution code:
def is_ok(X):
    cnt = 0
    for a in A:
        cnt += a//X
    if cnt <= k:
        return True
    else:
        return False


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

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

ans = meguru_bisect(0,max(A)+1)
if ans <= max(A):
    print(ans)
else:
    print(ans-1)

Submission status: Wrong Answer

Solution code:
def is_ok(X):
    cnt = 0
    for a in A:
        cnt += a//X
    if cnt <= k:
        return True
    else:
        return False


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

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

print(meguru_bisect(0,max(A)+1))

Submission status: Wrong Answer

Solution code:
def is_ok(X):
    cnt = 0
    for a in A:
        cnt += a//X
    if cnt <= k:
        return True
    else:
        return False


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

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

print(meguru_bisect(0,max(A)))

Submission status: Wrong Answer

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

    left = 1
    right = 10 ** 9 + 1
    while right - left > 1:
        mid = (right+left) // 2
        cnt = 0
        for a in A:
            cnt += (a-1) // mid
        
        if cnt <= K:
            right = mid
        else:
            left = mid

    print(right)
    
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

    left = 0
    right = 10 ** 9
    ans = None
    while right - left > 1:
        mid = (right+left) // 2
        cnt = 0
        for a in A:
            ceiled = -(-a // mid)
            cnt += ceiled - 1
        
        if cnt <= K:
            right = mid
        else:
            left = mid
        
        ans = mid
    
    print(int(-(-ans // 1))+1)
    
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

    left = 0
    right = 10 ** 9
    mid = (right+left) // 2
    while right - left > 1:
        cnt = 0
        for a in A:
            ceiled = -(-a // mid)
            cnt += ceiled - 1
        
        if cnt <= K:
            right = mid
        else:
            left = mid

        mid = (right+left) // 2
    
    print(int(-(-mid // 1)))
    
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

    left = 0
    right = 10 ** 9
    mid = (right+left) // 2
    while right - left > 1:
        cnt = 0
        for a in A:
            ceiled = -(-(a) // mid)
            cnt += ceiled - 1
        
        if cnt <= K:
            right = mid
        else:
            left = mid

        mid = (right+left) // 2
    
    print(int(-(-mid // 1)))
    
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

    left = 0
    right = 10 ** 9
    mid = (right+left) // 2
    while right - left > 1:
        cnt = 0
        for a in A:
            ceiled = -(-(a) // mid)
            if ceiled == a / mid:
                cnt += ceiled
            else:
                cnt += ceiled - 1
        
        if cnt <= K:
            right = mid
        else:
            left = mid

        mid = (right+left) // 2
    
    print(int(-(-mid // 1)))
    
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

    left = 1
    right = 10 ** 9 + 1
    mid = (right+left) / 2
    while right - left > 0.5:
        cnt = 0
        for a in A:
            ceiled = -(-(a) // mid)
            if ceiled == a / mid:
                cnt += ceiled
            else:
                cnt += ceiled - 1
        
        if cnt <= K:
            right = mid
        else:
            left = mid

        mid = (right+left) / 2
    
    print(int(-(-mid // 1)))
    
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
n,k=[int(i) for i in input().split()]
arr=[int(i) for i in input().split()]

l=1
h=10**9+10

def check(tar):
    if tar==0:
        sum=0
        for i in range(len(arr)):
            if arr[i]<=0:
                continue
            sum+=2*arr[i]-1
        if sum<=k:
            return True
        else:
            return False

    sum=0
    for i in range(len(arr)):
        if arr[i]<=tar:
            continue
        x=arr[i]//tar
        y=round(arr[i]/x)
        sum+=(x-1)
        if y!=tar:
            sum+=1
    if sum<=k:
        return True
    else:
        return False

while l!=h:
    m=(l+h)//2
    if check(m):
        h=m
    else:
        l=m+1
if l==1:
    print(0)
else:
    print(l)

Submission status: Wrong Answer

Solution code:
n,k=[int(i) for i in input().split()]
arr=[int(i) for i in input().split()]

l=1
h=10**9+10

def check(tar):
    if tar==0:
        sum=0
        for i in range(len(arr)):
            if arr[i]<=0:
                continue
            sum+=2*arr[i]-1
        if sum<=k:
            return True
        else:
            return False

    sum=0
    for i in range(len(arr)):
        if arr[i]<=tar:
            continue
        x=arr[i]//tar
        y=round(arr[i]/x)
        sum+=(x-1)
        if y!=tar:
            sum+=1
    if sum<=k:
        return True
    else:
        return False

while l!=h:
    m=(l+h)//2
    if check(m):
        h=m
    else:
        l=m+1
print(l)

Submission status: Wrong Answer

Solution code:
n,k=[int(i) for i in input().split()]
arr=[int(i) for i in input().split()]

l=0
h=10**3+10

def check(tar):
    if tar==0:
        sum=0
        for i in range(len(arr)):
            if arr[i]<=0:
                continue
            sum+=2*arr[i]-1
        if sum<=k:
            return True
        else:
            return False

    sum=0
    for i in range(len(arr)):
        if arr[i]<=tar:
            continue
        x=arr[i]//tar
        y=round(arr[i]/x)
        sum+=(x-1)
        if y!=tar:
            sum+=1
    if sum<=k:
        return True
    else:
        return False

while l!=h:
    m=(l+h)//2
    if check(m):
        h=m
    else:
        l=m+1
print(l)

Submission status: Wrong Answer

Solution code:
n,k=[int(i) for i in input().split()]
arr=[int(i) for i in input().split()]

l=0
h=10**9+10

def check(tar):
    if tar==0:
        sum=0
        for i in range(len(arr)):
            if arr[i]<=0:
                continue
            sum+=2*arr[i]-1
        if sum<=k:
            return True
        else:
            return False

    sum=0
    for i in range(len(arr)):
        if arr[i]<=tar:
            continue
        x=arr[i]//tar
        y=round(arr[i]/x)
        sum+=(x-1)
        if y!=tar:
            sum+=1
    if sum<=k:
        return True
    else:
        return False

while l!=h:
    m=(l+h)//2
    if check(m):
        h=m
    else:
        l=m+1
print(l)

Submission status: Wrong Answer

Solution code:
n,k=[int(i) for i in input().split()]
arr=[int(i) for i in input().split()]

l=0
h=10**9+10

def check(tar):
    if tar==0:
        sum=0
        for i in range(len(arr)):
            sum+=2*arr[i]-1
        if sum<=k:
            return True
        else:
            return False

    sum=0
    for i in range(len(arr)):
        if arr[i]<=tar:
            continue
        x=arr[i]//tar
        y=round(arr[i]/x)
        sum+=(x-1)
        if y!=tar:
            sum+=1
    if sum<=k:
        return True
    else:
        return False

while l!=h:
    m=(l+h)//2
    if check(m):
        h=m
    else:
        l=m+1
print(l)

Submission status: Wrong Answer

Solution code:
n,k=[int(i) for i in input().split()]
arr=[int(i) for i in input().split()]

l=1
h=10**9+10

def check(tar):
    sum=0
    for i in range(len(arr)):
        if arr[i]<=tar:
            continue
        x=arr[i]//tar
        y=round(arr[i]/x)
        sum+=(x-1)
        if y!=tar:
            sum+=1
    if sum<=k:
        return True
    else:
        return False

while l!=h:
    m=(l+h)//2
    if check(m):
        h=m
    else:
        l=m+1
print(l)

Submission status: Wrong Answer

Solution code:
n, k = [int(i) for i in input().split()]
woods = [int(i) for i in input().split()]


def k_cut_less_than(k, l, woods):
    kaisuu = 0
    for wood in woods:
        kaisuu += (wood-1) // l
    if kaisuu <= k:
        return False
    return True


# 二分探索
# functionを満たす,search_listの最大の要素を出力
# 【注意点】searchリストの初めの方はfunctionを満たし、後ろに行くにつれて満たさなくなるべき
import math


def binary_research(start, end,  function):
    if start == end:
        return start
    middle = math.ceil((start + end) / 2)
    if function(k, middle, woods):
        start = middle
    else:
        end = middle - 1
    return binary_research(start, end, function)

start=1
end=10**9
print(binary_research(start,end,k_cut_less_than)+1)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from decimal import Decimal, ROUND_HALF_UP


def main():
    N,K = list(map(int, sys.stdin.readline().split()))
    A_list = list(map(int, sys.stdin.readline().split()))


    def check(length :int) -> bool:
        cnt = 0

        for a in A_list:
            if a >= length:
                quotient = a / length
                divide = -(-quotient // 1)  # round up
                cnt += (divide - 1)
        
        return (True if cnt <= K else False)


    L = 0            # the minimum length
    R = max(A_list)  # the maximum length

    while (R - L) > 0.01:
        M = L + (R - L) / 2

        if check(M):
            R = M
        else:
            L = M
    
    
    ans = float( Decimal(str(M)).quantize(Decimal('1E-1'), rounding=ROUND_HALF_UP) )
    ans = -(-ans // 1)  # round up
    print( int(ans) )


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys


def main():
    N,K = list(map(int, sys.stdin.readline().split()))
    A_list = list(map(int, sys.stdin.readline().split()))


    def check(length :int) -> bool:
        cnt = 0

        for a in A_list:
            if a >= length:
                quotient = a / length
                divide = -(-quotient // 1)  # round up
                cnt += (divide - 1)
        
        return (True if cnt <= K else False)


    L = 0            # the minimum length
    R = max(A_list)  # the maximum length

    while (R - L) > 0.01:
        M = L + (R - L) / 2

        if check(M):
            R = M
        else:
            L = M
    
    
    ans = -(-M // 1)  # round up
    print( int(ans) )


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math

N,K=map(int,input().split())
A=list(map(int, input().split()))
l=0
r=max(A)
while not l+1==r:
    x=math.ceil((r+l)/2)
    k=0
    for a in A:
        k+=a//x
    if k<=K:
        r=x
    else:
        l=x
print(r)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int, input().split()))
l=0
r=max(A)
while not l+1==r:
    x=(r+l)//2
    k=0
    for a in A:
        k+=a//x
    if k<=K:
        r=x
    else:
        l=x
print(r)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int, input().split()))
l=0
r=max(A)+1
while not l+1==r:
    x=(r+l)//2
    k=0
    for a in A:
        k+=a//x
    if k<=K:
        r=x
    else:
        l=x
print(r)

Submission status: Wrong Answer

Solution code:
import math

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

left = 0
right = max(A)

while right - left > 1:
    mid = (left + right) // 2
    jk = 0
    for i in range(N):
        jk += A[i] // mid - 1
        if A[i] % mid == 0: jk += 1
    if jk <= K:
        right = mid
    else:
        left = mid

print(right)

Submission status: Wrong Answer

Solution code:
import math

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

left = 0
right = max(A)

while right - left > 1:
    mid = (left + right) // 2
    jk = 0
    for i in range(N):
        jk += A[i] / mid - 1
        if A[i] % mid == 0: jk += 1
    if jk <= K:
        right = mid
    else:
        left = mid

print(right)

Submission status: Wrong Answer

Solution code:
import math

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

left = 0
right = A[0]

while right - left > 1:
    mid = (left + right) // 2
    jk = 0
    for i in range(N):
        jk += A[i] / mid - 1
        if A[i] % mid == 0: jk += 1
    if jk <= K:
        right = mid
    else:
        left = mid

print(right)

Submission status: Wrong Answer

Solution code:
import math

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

left = 0
right = A[0]

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

print(right)

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int, input().split())
a=list(map(int, input().split()))
right=10**9
left=0
def cutable(a,x):
    count=0
    for i in a:
        count+=math.ceil(i/x)-1
    return count<=k    
while right>left+1:
    mid=(right+left)//2
    if cutable(a,mid):
        left=mid
    else:
        right=mid+1
print(math.ceil(max(a)/left))

Submission status: Wrong Answer

Solution code:
# E - Logs
import sys
sys.setrecursionlimit(1000000)

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

def rec(l,r):
    global N,K,A
    if l==r:
        return l
    tmp = (l+r)//2
    ans = 0
    for i in range(N):
        ans += A[i]//tmp
    if ans<=K:
        return rec(l,tmp)
    else:
        return rec(tmp+1,r)
    
print(rec(1,max(A)))

Submission status: Wrong Answer

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

def C(x):
  return sum([(A[i]+x-1)//x-1 for i in range(N)]) <= K
  
def binary_search2(func, n_min, n_max):
    left,right=n_min,n_max
    while right-left>1:
        middle = (left+right)//2
        y_middle = func(middle)
        if y_middle: right=middle
        else: left=middle

    return right
  
print(binary_search2(C, 1, max(A)))

Submission status: Wrong Answer

Solution code:
from math import ceil

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

def C(x):
  return sum([ceil(A[i]/x)-1 for i in range(N)]) <= K
  
def binary_search2(func, n_min, n_max):
    left,right=n_min,n_max
    while right-left>1:
        middle = (left+right)//2
        y_middle = func(middle)
        if y_middle: right=middle
        else: left=middle

    return right
  
print(binary_search2(C, 1, max(A)))

Submission status: Wrong Answer

Solution code:
from math import ceil

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

def C(x):
  return sum([(A[i]-.5)//x for i in range(N)]) <= K
  
def binary_search2(func, n_min, n_max):
    left,right=n_min,n_max
    while right-left>1:
        middle = (left+right)//2
        y_middle = func(middle)
        if y_middle: right=middle
        else: left=middle

    return right
  
print(binary_search2(C, 1, max(A)))

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int,input().split())
A = list(map(int,input().split()))
x = max(A)
y = 1
while True:
    if x == y:
        print(x)
        break
    z = (x+y)//2
    lst = [math.floor(A[i]/z)-1 for i in range(n)]
    if sum(lst) < k:
        y = z
    else:
        x = z

Submission status: Wrong Answer

Solution code:
A,B=input().split()
if int(A)<=8 and int(B)<=8:
  print("Yay!")
else:
  print( ":(")

Submission status: Wrong Answer

Solution code:
import math

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

line = list(map(int, input().split(" ")))

cnt = 0
high_X = max(line)
low_X = 0
X =(high_X + low_X) / 2

tree_ = 0

while True:
    cnt = 0
    X =(high_X + low_X) / 2
    min_tree = low_X
    for tree in line:
        if tree >= X:
            q, r = divmod(tree, X)
            if r == 0:
                q -= 1
            cnt += q
            ins_tree = tree / (q+1)
            if min_tree < ins_tree:
                min_tree = ins_tree
    tree_ = min_tree
    if cnt == K:
        break
    elif cnt > K:
        low_X = X
    else:
        high_X = X
        
print(math.ceil(tree_))

Submission status: Wrong Answer

Solution code:
import numpy as np

N, K = [int(x) for x in input().split()]
A = np.array([int(x) for x in input().split()])

L = np.max(A)

ans = L
low = 1
high = L
for i in range(L):
    if low == high:
        ans = low
        break
    mid = (low + high) // 2
    if np.sum(A // mid) <= K:
        high = mid
    else:
        low = mid + 1

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N, K = [int(x) for x in input().split()]
A = np.array([int(x) for x in input().split()])

L = np.max(A)

ans = L
low = 1
high = L
while 1:
    if low == high:
        ans = low
        break
    mid = (low + high) // 2
    if np.sum(A // mid) <= K:
        high = mid
    else:
        low = mid + 1

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N, K = [int(x) for x in input().split()]
A = np.array([int(x) for x in input().split()])

L = np.max(A)

ans = L
low = 1
high = L
while 1:
    print(str(low) + ' ' + str(high))
    if low == high:
        ans = low
        break
    mid = (low + high) // 2
    if np.sum(A // mid) <= K:
        high = mid
    else:
        low = mid + 1

print(ans)

Submission status: Wrong Answer

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

def f(length, ls):
    cur = 0
    for a in ls:
        cur += a//length
    if cur <= K:
        return True
    else:
        return False

ok, ng = max(A), 0
while abs(ok - ng) > 1:
    z = (ok+ng)//2
    if f(z, A) == True:
        ok = z
    else:
        ng = z
print(ok)

Submission status: Wrong Answer

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

l = 1
r = 10**9 + 1
while r - l > 1:
    m = (l+r) // 2
    cnt = 0
    for i in a:
        cnt += math.ceil(i / m) - 1
    if cnt <= k:
        r = m
    else:
        l = m
print(l+1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

def solve(*args: str) -> str:
    n, k = map(int, args[0].split())
    A = tuple(map(int, args[1].split()))

    l, r = 1, max(A)
    while l+1 < r:
        m = (l+r)//2
        cnt = 0
        for a in A:
            cnt += -(-a//m)-1

        if k < cnt:
            l = m
        else:
            r = m

    return str(r)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Wrong Answer

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    n, k = map(int, args[0].split())
    A = tuple(map(int, args[1].split()))

    l, r = 0, max(A)
    while l+0.5 < r:
        m = (l+r)/2
        cnt = 0
        for a in A:
            cnt += -int(-a//m)-1

        if k < cnt:
            l = m
        else:
            r = m

    return str(-int(-l//1))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Wrong Answer

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    n, k = map(int, args[0].split())
    A = tuple(map(int, args[1].split()))

    l, r = 0, max(A)
    while l+1 < r:
        m = (l+r)/2
        cnt = 0
        for a in A:
            cnt += -int(-a//m)-1

        if k < cnt:
            l = m
        else:
            r = m

    return str(-int(-l//1))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Wrong Answer

Solution code:
# 入力
# 値は全てint
# Nは本数、Kは切る回数、AはN本の木のそれぞれの長さ(リスト)
N,K = map(int,input().split())
A = list(map(int,input().split()))

# 二分探索
# lが左端、rが右端
l,r = 1, 10**9+1

# 整数で返すので、差が１より大きい時はループする
while r - l > 1:
    # 真ん中を設定
    x = (r+l) // 2

    # 切る回数をc
    c = 0
    for a in A:
        # それぞれの丸太の(長さ-1)をxで割った値の合計が、切る回数
        c += (a-1) // x 

    # 切る回数がKよりも小さい時はOKなので右端を寄せる
    if c <= 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,=map(int,input().split())

def C(x):
  return sum([(A[i]-1)//x for i in range(N)]) <= K
  
def binary_search2(func, n_min, n_max):
    left,right=n_min,n_max
    while right-left>1:
        middle = (left+right)//2
        y_middle = func(middle)
        if y_middle: right=middle
        else: left=middle

    return right
  
print(binary_search2(C, 1, max(A)))

Submission status: Wrong Answer

Solution code:
from math import ceil

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

def C(x):
  return sum([(A[i]-1)//x for i in range(N)]) <= K
  
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
  
print(binary_search2(C, 1, max(A))+1)