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 = 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.01
        Cancut = X
    else:
        low  = X + 0.01
# 出力
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
    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:
##a = int(stdin.readline().rstrip())
##b, c = [int(x) for x in stdin.readline().rstrip().split()]
##s = stdin.readline().rstrip()
##a = list(set(b))  重複を削除
##a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()])) a[0, 1, 2, ...]
##a = [[0] * 2 for _ in range(n)]  a[0,0]
##v = [s[i: i+2] for i in range(0, len(s), 2)]
##  s="12345678" を v=["12","34","56","78"] にするイメージ
##s = "".join(list)リストを文字列に変換[""]は区切り文字
##a.sort(key=itemgetter(1))リストをソートできるよ(from operator import itemgetterが必要)
##sort_p = sorted(p) 昇順ソート

# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
import numpy as np
import random
import bisect
import copy
# stdin = open("sample.txt")


MOD = int(1e9+7)
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

def keta(kazu): # 入力されたintを桁ごとに分解，リストで出力
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): # 最小公倍数
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  # (x**n)の計算の高速化
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def fact(n): # nの素因数分解の結果を辞書で出力 fuct(24) → {2: 3, 3: 1}
    arr = {}
    temp = n
    for i in range(2,int(n**0.5)+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt
    if temp != 1:
        arr[temp] = 1
    if arr == {}:
        arr[n] = 1
    return arr
    
def f(n,a,c,K):
    now = 0
    for i in range(n):
        now += math.ceil(a[i]/c)-1
    return now <= K

def main():
    N,K = [int(x) for x in stdin.readline().rstrip().split()]
    A = list(map(int,[int(x) for x in stdin.readline().rstrip().split()]))
    l,r = 0,int(1e9)
    while r-l > 1:
        c = (l+r)//2
        print(c,f(N,A,c,K))
        if f(N,A,c,K):
            r = c
        else:
            l = c
            
    print(r)
main()

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

# 出力
print(int(X)+1)

Submission status: Wrong Answer

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

def is_ok(arg):
  cnt=0
  for i in a:
    cnt+=(i-1)//arg
  return k>=cnt
  
def binsearch(ng,ok):
  while abs(ok-ng)>1:
    mid=(ok+ng)//2
    if is_ok(mid):
      ok=mid
    else:
      ng=mid
      
  return ok

print(binsearch(1,10**9+1))

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

# 出力
print(int(X)+1)

Submission status: Wrong Answer

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

l, r = 1, 10 ** 9
while l < r:
    m = (l + r) // 2
    if sum(map(lambda v: (v - 1) // m, a)) > k:
        l = m + 1
    else:
        r = m
print(l, r)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

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

def isOK(minVal):
	tmpK=0
	for a in A:
		# math.ceil(a//minVal)-1
		tmpK+=((-(-a//minVal))-1)

	if tmpK <= K:
		return True
	else:
		return False

ok = max(A)
ng = 0

while (math.ceil(ok) != math.ceil(ng)):
	mid = (ok+ng) / 2
	if isOK(mid):
		ok = mid
	else:
		ng = mid
	print(ok,ng)

print(math.ceil(ok))

Submission status: Wrong Answer

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

def can_cut(n):
    tmp = 0
    for a in A:
        tmp += ((a + n - 1) // n) - 1
    if tmp <= K:
        return True
    else:
        return False

l = 1
r = max(A)
while l+1 < r:
    m = (l + r) // 2
    if can_cut(m):
        r = m
    else:
        l = m
print(r)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
tmax=max(a)
tmin=0
import math
ans=tmax
if k==0:
  print(tmax)
else:
  while True:
    t=(tmax+tmin)/2
    if abs(tmax-tmin)<0.01:
      break
    s=0
    for i in range(n):
      s=s+math.ceil(a[i]/t)-1
    if k>=s:
      ans=min(math.ceil(t),ans)
      tmax=t
    else:
      tmin=t
  print(math.ceil(tmax))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
tmax=max(a)
tmin=0
import math
ans=tmax
if k==0:
  print(tmax)
else:
  while True:
    t=(tmax+tmin)/2
    if abs(tmax-tmin)<0.01:
      break
    s=0
    for i in range(n):
      s=s+math.ceil(a[i]/t)-1
    if k>=s:
      ans=min(math.ceil(t),ans)
      tmax=t
    else:
      tmin=t
  print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
tmax=max(a)
tmin=0
import math
ans=tmax
if k==0:
  print(tmax)
else:
  while True:
    t=(tmax+tmin)/2
    if tmax-tmin<0.01:
      break
    s=0
    for i in range(n):
      s=s+math.ceil(a[i]/t)-1
    if k>=s:
      ans=min(math.ceil(t),math.ceil(ans))
      tmax=t
    else:
      tmin=t
  print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
tmax=max(a)
tmin=0
t=(tmax+tmin)/2
import math
ans=tmax
if k==0:
  print(tmax)
else:
  while True:
    s=0
    for i in range(n):
      s=s+math.ceil(a[i]/t)-1
    if k>=s:
      ans=min(math.ceil(t),math.ceil(ans))
      tmax=t
      t=(tmin+t)/2
    else:
      tmin=t
      t=(t+tmax)/2
    if tmax-tmin<0.01:
      break
  print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
tmax=max(a)
tmin=0
t=(tmax+tmin)/2
import math
ans=tmax
if k==0:
  print(tmax)
else:
  while True:
    s=0
    for i in range(n):
      s=s+math.ceil(a[i]/t)-1
    if k>=s:
      ans=min(t,ans)
      tmax=t
      t=(tmin+t)/2
    else:
      tmin=t
      t=(t+tmax)/2
    if tmax-tmin<0.01:
      break
  print(math.ceil(ans))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
tmax=max(a)
tmin=0
t=(tmax+tmin)/2
import math
ans=0
if k==0:
  print(tmax)
else:
  while True:
    s=0
    for i in range(n):
      s=s+math.ceil(a[i]/t)-1
    if k>=s:
      ans=t
      tmax=t
      t=(tmin+t)/2
    else:
      tmin=t
      t=(t+tmax)/2
    if tmax-tmin<0.001:
      break
  print(math.ceil(ans))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
tmax=max(a)
tmin=0
t=(tmax+tmin)/2
import math
ans=0
if k==0:
  print(tmax)
else:
  while True:
    s=0
    for i in range(n):
      s=s+math.ceil(a[i]/t)-1
    if k>=s:
      ans=t
      tmax=t
      t=(tmin+t)/2
    else:
      tmin=t
      t=(t+tmax)/2
    if tmax-tmin<0.01:
      break
  print(math.ceil(ans))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
tmax=max(a)
tmin=0
t=(tmax+tmin)/2
import math
ans=0
if k==0:
  print(tmax)
else:
  while True:
    s=0
    for i in range(n):
      s=s+math.ceil(a[i]/t)-1
    if k>=s:
      ans=t
      tmax=t
      t=(tmin+t)/2
    else:
      tmin=t
      t=(t+tmax)/2
    if tmax-tmin<0.1:
      break
  print(math.ceil(ans))

Submission status: Wrong Answer

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

b = 0
e = max(A)
L = e // 2
while e - b > 1:
    m = sum(list(map(lambda x: x // L, A)))
    if m <= k:
        e = L
        L = (e + b) // 2
    else:
        b = L
        L = (e + b) // 2
print(e)

Submission status: Wrong Answer

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

for j in range(K):
    y = A.pop()
    z = y[0]*(y[1]+1)/(y[1]+2)
    zz = y[1]+1
    bisect.insort(A,[z,zz])
print(A)
print(math.ceil(A[-1][0]))

Submission status: Wrong Answer

Solution code:
import math

N,K = map(int, input().split())
A_list = [int(e) for e in input().split()]

ans_max = max(A_list)
ans_min = 1

while 1:    
    if ans_max - ans_min <= 4:
        break
    
    temp_ans = ans_min + (ans_max - ans_min)//2
    temp_K = sum([math.ceil(A/temp_ans)-1 for A in A_list])
    
    if temp_K > K:
        ans_min = temp_ans
    else:
        ans_max = temp_ans
        
for i in range(ans_min,ans_max+1):
    temp_K = sum([math.ceil(A/i)-1 for A in A_list])

    if temp_K == K:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
"""
AtCoder :: Beginner Contest 174 :: Logs
https://atcoder.jp/contests/abc174/tasks/abc174_e
"""
import sys


def main():
    """Main program."""
    log_count, cut_count = (int(i) for i in sys.stdin.readline().split())
    logs = [int(i) for i in sys.stdin.readline().split()]
    high = max(logs)
    low = 1
    soln = high
    # Binary search for the answer.
    while low < high:
        mid = (low + high) // 2
        cuts_needed = 0
        if mid:
            cuts_needed = sum(log // mid for log in logs)
        if cuts_needed <= cut_count:
            soln = min(soln, mid)
            high = mid - 1
        else:
            low = mid + 1
    print(soln)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
"""
AtCoder :: Beginner Contest 174 :: Logs
https://atcoder.jp/contests/abc174/tasks/abc174_e
"""
import sys


def main():
    """Main program."""
    log_count, cut_count = (int(i) for i in sys.stdin.readline().split())
    logs = [int(i) for i in sys.stdin.readline().split()]
    high = max(logs)
    low = 0
    soln = high
    # Binary search for the answer.
    while low < high:
        mid = (low + high) // 2
        cuts_needed = 0
        if mid:
            cuts_needed = sum(log // mid for log in logs)
        if cuts_needed <= cut_count:
            soln = min(soln, mid)
            high = mid - 1
        else:
            low = mid + 1
    print(soln)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if K != 0:
  ans = ["0" for _ in range(30)]
  for x in range(30):
    ans[x] = "1"
    tmp = int("".join(ans),2)
    sum_cut = sum([math.floor(a/tmp) for a in A])
    if sum_cut <= K:
      ans[x] = "0"
  answer = int("".join(ans),2) + 1
else:
  answer = max(A)
print(answer)

Submission status: Wrong Answer

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

if K != 0:
  ans = ["0" for _ in range(30)]
  for x in range(30):
    ans[x] = "1"
    tmp = int("".join(ans),2)
    sum_cut = sum([math.floor(a/tmp) for a in A])
    if sum_cut <= K:
      ans[x] = "0"
  answer = int("".join(ans),2) + 1
else:
  answer = len([a for a in A if a<=N])
print(answer)

Submission status: Wrong Answer

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n,k = lr()
a = lr()

def getK(num):
    ret = 0
    for tmp in a:
        while tmp > num:
            tmp = tmp/2
            ret+=1
    return ret

ans = 0
l = 0
r = max(a)
while l < r:
    mid = l + (r-l) // 2
    if getK(mid) < k:
        r = mid
    else:
        l = mid+1
    ans = l
print(math.ceil(ans))

Submission status: Wrong Answer

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n,k = lr()
a = lr()

def getK(num):
    ret = 0
    for tmp in a:
        while tmp > num:
            tmp = tmp/2
            ret+=1
    return ret

ans = 0
l = 0
r = max(a)
while l <= r:
    mid = l + (r-l) // 2
    if getK(mid) < k:
        r = mid
    else:
        l = mid+1
    if l >= r:
        ans = l
        break
print(math.ceil(ans))

Submission status: Wrong Answer

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n,k = lr()
a = lr()

def getK(num):
    ret = 0
    for tmp in a:
        while tmp > num:
            tmp = tmp/2
            ret+=1
    return ret

ans = 0
l = 0
r = max(a)
while l <= r:
    mid = l + (r-l) // 2
    if getK(mid) < k:
        r = mid-1
    else:
        l = mid+1
    if l > r:
        ans = mid
        break
print(math.ceil(ans))

Submission status: Wrong Answer

Solution code:
def resolve():
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    import math
    def isok(n):
        ndiv = 0
        for a in A:
            if a <= n:
                continue
            ndiv += math.ceil(a/n)-1
        return True if ndiv <= K else False 
    left = 1
    right = 10**9+1
    while (right - left) > 1:
        mid = left + (right - left) // 2
        if isok(mid):
            right = mid
        else:
            left = mid
    print(math.ceil(right))


if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
import sys

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

n,k=2,3
a=[7, 9]

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

def rf(mm):
    if mm==0:
        mm=1
    icnt=0
    for i in range(n):
        icnt+=(a[i]-1)//mm+1
    return icnt

asum=sum(a)
m=asum//(n+k)
um=asum
lm=1
for ii in range(60):
    if m==1:
        break
    rfm=rf(m)
    if rfm<=(n+k) and rf(m-1)>(n+k):
        break
    if um-lm<5:
        break
    if rfm>(n+k):
        lm=m
        m=(um+lm)//2-1
    elif rfm<(n+k):
        um=m
        m=(um+lm)//2-1
    else:
        um=m-1
        m=(um+lm)//2-1

if um<1:
    print(1)
    sys.exit()
    
for mi in range(um,max(0,lm-1),-1):
    if rf(mi)<=(n+k) and rf(mi-1)>(n+k):
        break

print(mi)

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
aas = list(map(int, input().split()))
diff = pow(10,-6)
left = 1
right = 10**9
def judge(mid):
    cut = 0
    for i in aas:
        cut += math.ceil(i / mid) - 1
    if cut <= k:
        return True
    else:
        return False
while left < right:
    mid = (left + right) / 2
    if (left <= right <= left + diff) or (right <= left <= right + diff):
        break
    elif judge(mid):
        right = mid
    else:
        left = mid
print(int(right))

Submission status: Wrong Answer

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

left = 1
right= max(A)

import math

while True:
  
  #cl = 0
  #for i in range(N):
  #  cl += math.ceil(A[i]/left) - 1
  #cr = 0
  #for i in range(N):
  #  cr += math.ceil(A[i]/right) - 1
  
  mid = (left + right)//2
  cm = 0
  for i in range(N):
    cm += math.ceil(A[i]/mid) - 1
  #if(cl<=K):
  #  break
  if(cm<=K):
    right = mid
  else:
    left = mid
  if(abs(left-right)<=1):
    break

cm2 = 0
for i in range(N):
    cm2 += math.ceil(A[i]/left) - 1
    
if(cm2<=K):
  print(left)
else:
  print(mid)

Submission status: Wrong Answer

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

left = 1
right= max(A)

import math

while True:
  
  #cl = 0
  #for i in range(N):
  #  cl += math.ceil(A[i]/left) - 1
  #cr = 0
  #for i in range(N):
  #  cr += math.ceil(A[i]/right) - 1
  
  mid = (left + right)//2
  cm = 0
  for i in range(N):
    cm += math.ceil(A[i]/mid) - 1
  #if(cl<=K):
  #  break
  if(cm<=K):
    right = mid
  else:
    left = mid
  if(abs(left-right)<=1):
    break

cm2 = 0
for i in range(N):
    cm2 += math.ceil(A[i]/math.floor(mid)) - 1
    
if(cm2<=K):
  print(math.floor(mid))
else:
  print(math.ceil(mid))

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
aas = list(map(int, input().split()))
diff = pow(10,-6)
left = 1
right = 10**9
def judge(mid):
    cut = 0
    for i in aas:
        cut += math.ceil(i / mid) - 1
    if cut <= k:
        return True
    else:
        return False
while left < right:
    mid = (left + right) / 2
    if (left <= right <= left + diff) or (right <= left <= right + diff):
        break
    elif judge(mid):
        right = mid
    else:
        left = mid
print(math.ceil(right))

Submission status: Wrong Answer

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

left = 1
right= max(A)

import math

while True:
  
  #cl = 0
  #for i in range(N):
  #  cl += math.ceil(A[i]/left) - 1
  #cr = 0
  #for i in range(N):
  #  cr += math.ceil(A[i]/right) - 1
  
  mid = (left + right)/2
  cm = 0
  for i in range(N):
    cm += math.ceil(A[i]/mid) - 1
  #if(cl<=K):
  #  break
  if(cm<=K):
    right = mid
  else:
    left = mid
  if(abs(left-right)<10e-1):
    break

cm2 = 0
for i in range(N):
  cm2 += math.ceil(A[i]/math.floor(left)) - 1
    
if(cm2<=K):
  print(math.floor(left))
else:
  print(math.ceil(mid))

Submission status: Wrong Answer

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

left = 1
right= max(A)

import math

while True:
  
  #cl = 0
  #for i in range(N):
  #  cl += math.ceil(A[i]/left) - 1
  #cr = 0
  #for i in range(N):
  #  cr += math.ceil(A[i]/right) - 1
  
  mid = (left + right)/2
  cm = 0
  for i in range(N):
    cm += math.ceil(A[i]/mid) - 1
  #if(cl<=K):
  #  break
  if(cm<=K):
    right = mid
  else:
    left = mid
  if(abs(left-right)<10e-1):
    break

cm2 = 0
for i in range(N):
    cm2 += math.ceil(A[i]/math.floor(mid)) - 1
    
if(cm2<=K):
  print(math.floor(mid))
else:
  print(math.ceil(mid))

Submission status: Wrong Answer

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

left = 1
right= max(A)

import math

while True:
  
  #cl = 0
  #for i in range(N):
  #  cl += math.ceil(A[i]/left) - 1
  #cr = 0
  #for i in range(N):
  #  cr += math.ceil(A[i]/right) - 1
  
  mid = (left + right)/2
  cm = 0
  for i in range(N):
    cm += math.ceil(A[i]/mid) - 1
  #if(cl<=K):
  #  break
  if(cm<=K):
    right = mid
  else:
    left = mid
  if(abs(left-right)<10e-5):
    break
    
print(math.ceil(mid))
#print(right)
#print(left)

Submission status: Wrong Answer

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

left = 1
right= max(A)

import math

while True:
  
  #cl = 0
  #for i in range(N):
  #  cl += math.ceil(A[i]/left) - 1
  #cr = 0
  #for i in range(N):
  #  cr += math.ceil(A[i]/right) - 1
  
  mid = (left + right)/2
  cm = 0
  for i in range(N):
    cm += math.ceil(A[i]/mid) - 1
  #if(cl<=K):
  #  break
  if(cm<=K):
    right = mid
  else:
    left = mid
  if(abs(left-right)<10e-2):
    break
    
print(math.ceil(mid))
#print(right)
#print(left)

Submission status: Wrong Answer

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

left = 1
right= max(A)

import math

while True:
  
  #cl = 0
  #for i in range(N):
  #  cl += math.ceil(A[i]/left) - 1
  #cr = 0
  #for i in range(N):
  #  cr += math.ceil(A[i]/right) - 1
  
  mid = (left + right)//2
  cm = 0
  for i in range(N):
    cm += math.ceil(A[i]/mid) - 1
  #if(cl<=K):
  #  break
  if(cm<=K):
    right = mid
  else:
    left = mid
  
  if(left>=right-1):
    break
    
print(right)

Submission status: Wrong Answer

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

left = 1
right= max(A)

import math

dict_X = {}
while True:
  
  cl = 0
  for i in range(N):
    cl += math.ceil(A[i]/left) - 1
  cr = 0
  for i in range(N):
    cr += math.ceil(A[i]/right) - 1
  
  mid = (left + right)//2
  cm = 0
  for i in range(N):
    cm += math.ceil(A[i]/mid) - 1
  if(cl<=K):
    break
  elif(cm<=K):
    right = mid
  else:
    left = mid
  
  if(left>=right-1):
    break
    
print(right)

Submission status: Wrong Answer

Solution code:
N,K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
M = max(A)
m = 1
mid = M//2
while m<M:
  n = 0
  for a in A:
    n += -(-a//mid)-1
    if n > K:
      m = mid+1
      break
  else:
    M = mid
  mid = (M+m)//2
print(mid)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
L = 0
R = max(A)
while R-L > 0.001:
    X = (L+R)/2
    m = 0
    for i in range(N):
        c = A[i]/X
        if c == int(c):
            m += int(c) - 1
        else:
            m += int(c)
    if m <= K:
        R = X
    else:
        L = X
print(int(R)+1)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
L = 0
R = max(A)
while R-L > 0.001:
    X = (L+R)/2
    m = 0
    for i in range(N):
        c = A[i]/X
        if c == int(c):
            m += int(c) - 1
        else:
            m += int(c)
    if m <= K:
        R = X
    else:
        L = X
print(int(R))

Submission status: Wrong Answer

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

hi = 10 ** 9
lo = 1
while hi - lo > 1:
    mid = (hi + lo) // 2

    cnt = 0
    for v in a:
        cnt += (v + mid - 1) // mid - 1

    if cnt <= k:
        hi = mid
    else:
        lo = mid

print(hi)