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:
import sys
import  math
import fractions
from collections import defaultdict
import heapq
from bisect import bisect_left,bisect

stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K=nm()
A=nl()
l=1
r=10**9
mid=0

if(K==0):
    print(max(A))
    sys.exit(0)

while(l+1<r):
    mid=(l+r)//2
    tmp=0
    for i in range(len(A)):
        tmp+=A[i]//mid
    if(K<tmp):
        l=mid
    else:
        r=mid

tmp=0
for i in range(len(A)):
    tmp+=A[i]//l

if(K<=tmp):
    print(r)
    sys.exit(0)
else:
    print(l)
    sys.exit(0)

Submission status: Wrong Answer

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

for k in range(K):
    i = A.index(max(A))
    A[i] = A[i]/2

print(math.ceil(max(A)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
xlist = []
wa = sum(a)
for i in a:
  xlist.append((k+n)*i/wa)

xlist_int = []
ans_kouho = []
for i in range(n):
  j = int(xlist[i])
  if j == 0:
    j = 1
    ans_kouho.append(a[i])
  xlist_int.append(j)

amari = n+k-sum(xlist_int)
xlist_hi = [xlist_int[i]/xlist[i] for i in range(n)]
xlist_hi.sort()
ans1 = math.ceil(wa/(k+n)/xlist_hi[amari])
ans2 = 0
if len(ans_kouho) >= 1:
  ans2 = max(ans_kouho)

if ans1 >= ans2:
  ans = ans1
else:
  ans = ans2

print(ans)

Submission status: Wrong Answer

Solution code:
def check(A, K, L):
    i = 0
    for a in A:
        i += a//L
        if i > K:
            return False
    return True

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort(reverse=True)
l = 0
r = A[0]
while l + 1 < r:
    m = (l+r)//2
    if check(A, K, m):
        r = m
    else:
        l = m
print(l+1)

Submission status: Wrong Answer

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

hi = 10**18
lo = 1

while hi - lo > 1:
    mid = (hi + lo) // 2
    cut = 0
    for i in range(N):
        cut += (A[i] + mid - 1) // mid - 1
    if cut <= K:
        hi = mid
    else:
        lo = mid

print(hi)

Submission status: Wrong Answer

Solution code:
## coding: UTF-8
import math

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


ok = A[-1]
ng = 0

#print(math.ceil(40 / 10.0) - 1)

def hantei(p):
    cnt = 0
    for i in range(N):
        cnt += math.ceil(A[i] / p - 1)
        #print(A[i], 'done', cnt)
    #print('~~~')
    #print(p, cnt, K)
    if(cnt > K):
        #ng
        return 'ng'
    else:
        return 'ok'



def shisya(ans):
    if((ans - ans // 1) >= 0.5):
        return(int(ans//1+1))
    else:
        return(int(ans//1))   



while shisya(ok)-shisya(ng) >= 1:
    mid = (ok+ng)/2
    if(hantei(mid) == 'ng'):
        ng = mid
    else:
        ok = mid
    #print(ok, ng)

print(shisya(ok))

Submission status: Wrong Answer

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

def check(N, K, A, L):
    return sum(a // L for a in A) <= K

answer=max(A)
lo = 1
hi = answer+1
while lo < hi:
    m = (lo + hi)//2
    ok = check(N, K, A, m)
    if ok: # 
        answer=m
        hi=m
    else:
        lo=m+1
print(min(max(A), answer))

Submission status: Wrong Answer

Solution code:
from math import ceil
n,k=map(int,input().split())
a=list(map(int,input().split()))
if k==0:
    print(max(a))
    exit()
a.sort()
left,right=0,a[n-1]
mid=right
while abs(right-left)>2:
    mid=(left+right)/2
    temp=0
    for i in range(n-1,-1,-1):
        if a[i]<=mid: break
        temp+=a[i]//mid
    if temp>k: left=mid
    else: right=mid
mid=ceil(mid)-3
while True:
    temp=0
    flag=0
    for i in range(n-1,-1,-1):
        if a[i]<=mid: break
        temp+=a[i]//mid
    if temp>k: mid+=1
    else:
        flag=1
        break
    if flag: break
print(int(mid))

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N,K = map(int,input().split())
A = list(map(int,input().split()))
S = 0
for i in range(N):
    S += A[i]
vmin = 0
if K == 0:
    print(max(A))
else:
    for i in range(N):
        a = A[i]
        kk = a/math.ceil(1+a*K/S)
        vmin = max(vmin,kk)
    v = math.ceil(vmin)
    p = max(11,v)
    for i in range(p-10,p+20):
        c = 0
        if i == 1:
            for j in range(N):
                a = A[j]
                c += a-1
        else:           
            for jj in range(N):
                a = A[jj]
                c += (a-1) // i 
        if c <= K:
            print(i)
            break

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import math
n,k = map(int,input().split())
log_list = list(map(float,input().split()))
log_list.sort()

cut_count = 0
while cut_count < k:
    max_index = log_list[n-1]
    next_index = log_list[n-2]
    div_count = 2
    while(log_list[n-1] / div_count >= log_list[n-2]):
        div_count+=1
    log_list[n-1] = log_list[n-1] / div_count
    cut_count += div_count - 1
    log_list.sort()

print(log_list)
print(math.ceil((max(log_list))))

Submission status: Wrong Answer

Solution code:
import queue
import math


def m():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    base = K // N
    rest = K % N

    q = queue.PriorityQueue()
    for a in A:
        x = a / (base + 1)
        q.put([-x, base + 1, a])

    for i in range(rest):
        tmp = q.get()
        x = tmp[2] / (tmp[1] + 1)
        q.put([-x, tmp[1] + 1, tmp[2]])

    B = []
    while not q.empty():
        B.append(-q.get()[0])
    ans = max(B)
    return math.ceil(ans)


print(m())

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
A = list(map(int, input().split()))
if k == 0:
    print(max(A))
    exit()
ans = -(-sum(A) // (n+k))
print(ans)

Submission status: Wrong Answer

Solution code:
import copy

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

devide = [ 0 for _ in range( n ) ]
dev_len = copy.deepcopy( a )

for _ in range( k ):
    max_i = dev_len.index( max( dev_len ) )
    devide[ max_i ] += 1
    dev_len[ max_i ] = a[ max_i ] / ( devide[ max_i ] + 1 )

print( int( max( dev_len ) + 0.5 ) )

Submission status: Wrong Answer

Solution code:
import sys
import math
import heapq
push = heapq.heappush
pop = heapq.heappop
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,k = map(int,readline().split())
rest = k
lst1 = list(map(int,readline().split()))
hp = []
for i in lst1:
    push(hp,(-i,i,1))

while rest:
    res = pop(hp)
    res2 = [0]*3
    times = max(1,rest//n)
    res2[0] = -res[1]/(res[2]+times)
    res2[1] = res[1]
    res2[2] = res[2]+times
    rest -= times
    push(hp,tuple(res2))

print(math.ceil(-pop(hp)[0]))

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=sorted(list(map(int,input().split())))
if K==0:print(max(A));exit()

left,right=0,10**9+1
while right>left+1:
    cnt=K
    mid=(left+right)//2
    for i in range(N):
        cnt -=A[i]//mid
    if cnt>0:right=mid
    elif cnt<0:left=mid
    elif cnt==0:
        while right>left+1:
            cnt1,cnt2=K,K
            mid=(left+right)//2
            for i in range(N):
                cnt1 -=A[i]//mid
            for i in range(N):
                cnt2 -=A[i]//(mid+1)
            if cnt1==0 and cnt2==0:right=mid
            elif cnt1!=0 and cnt2!=0:left=mid
            else:break
        ans=10**10
        for i in range(left,right+1):
            cnt=K
            for j in range(N):
                cnt -=A[j]//i
            if cnt==0:
                ans=min(ans,i)
        print(ans)
        exit()

Submission status: Wrong Answer

Solution code:
#import numpy as np
#import collections
#import math

#f = open('./input_E.txt')
#
#N,K = map(int, f.readline().split())
#A = list(map(int, f.readline().split()))

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

if K == 0:
    ans = max(A)
else:
    A.sort(reverse=True)
    
    All_length = sum(A)
    KK = K+N-1
    lm = All_length/(KK+1)
    
    k_list = [int(Ai//lm) for Ai in A]
    X_list = [Ai%lm for Ai in A]
    
    sum_k = sum(k_list)
    res_cut = KK-sum_k
    
    zero_k = 0
    for i in range(1,N+1):
        if k_list[-i] == 0:
            zero_k +=1
        else:
            break
    
    if res_cut > 0:
        think = N//res_cut+1
        ans_kouho = []
        for i in range(-zero_k,0):
            ans_kouho.append(X_list[i])
#        for i in range(res_cut):
        for i in range(think):
            for j in range(N-zero_k):
                ans_kouho.append((X_list[j]-i*lm)/k_list[j])
        
        ans_kouho.sort(reverse=True)
        ans = ans_kouho[res_cut] + lm
        ans = int(ans)+1
    else:
        ans = int(lm)+1
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
ok=max(a)
ng=0
while ok-ng>1:
    mid=(ok+ng)//2
    cnt=0
    for i in range(n):
        num=a[i]
        cnt+=num//mid
    if cnt<=k:
        ok=mid
    else:
        ng=mid
print(ok)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
M = max(A)
m = min(A)
def calc(r):
    return pow(2,r-1)-1
l,r = 1,M
cnt = 0
import math
while l<r:
    cnt = 0
    mid = (l+r)//2
    for a in A:
        cnt += a//mid
    if cnt <=k:
        r = mid-1
    else:
        l = mid+1
print(l)

Submission status: Wrong Answer

Solution code:
import heapq
from decimal import Decimal
from math import ceil
n, k = map(int, input().split())
a = list(map(Decimal, input().split()))
a = list(map(lambda x: - x, a))
heapq.heapify(a)
for _ in range(k):
    tmp = heapq.heappop(a)
    tmp /= 2
    heapq.heappush(a, tmp)

print(ceil(heapq.heappop(a)*-1))

Submission status: Wrong Answer

Solution code:
from math import ceil

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

l_lb, l_min = 1, max(A)
while l_min - l_lb > 1:
  l_mid = (l_lb + l_min) // 2
  if sum(ceil(a/l_mid) for a in A) - N > K:
    l_lb = l_mid
  else:
    l_min = l_mid
print(l_min)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
if k==0:
    print(max(a))
else:
    ans=0
    for i in a:
        d=-(-k*i//sum(a))
        if d>0:
            ans=max(ans,-(-i//(d+1)))
        else:
            ans=max(ans,i)
    print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil
n,k=map(int,input().split())
a=list(map(int,input().split()))
if k==0:
    print(max(a))
    exit()
a.sort()
left,right=0,a[n-1]
mid=right
while abs(right-left)>1:
    mid=(left+right)/2
    temp=0
    for i in range(n-1,-1,-1):
        if a[i]<=mid: break
        temp+=a[i]//mid
    if temp>k: left=mid
    else: right=mid
mid=ceil(mid)-2
while True:
    temp=0
    flag=0
    for i in range(n-1,-1,-1):
        if a[i]<=mid: break
        temp+=a[i]//mid
    if temp>k: mid+=1
    else:
        flag=1
        break
    if flag: break
print(mid)

Submission status: Wrong Answer

Solution code:
from math import ceil
n,k=map(int,input().split())
lst=list(map(int,input().split()))
ng=1
ok=10**9+1
while ok-ng>1:
    mid=(ok+ng)//2
    tmp=0
    for i in range(n):
        tmp+=ceil(lst[i]/mid)-1
    if tmp>k:
        ng=mid
    else:
        ok=mid
print(ok)

Submission status: Wrong Answer

Solution code:
import sys
import math

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def cc(al, v_max, k):
	for v in al:
		if v < v_max:
			return True
		k -= -(-v // v_max)-1
		#pa((k, -(-v // v_max)))
		if k < 0:
			return False
	return True
		

def main():
	#a = int(input())
	n, k = tin()
	#s = input()
	al = lin()
	al.sort(reverse = True)
	#print(al)
	ok = al[0]
	ng = 0.01
	while ok - ng > 0.001:
		mid = (ok + ng)/2
		ii=cc(al, mid, k)
		#pa((mid,ii))
		if ii:
			ok = mid
		else:
			ng = mid
	#pa(ok)
	math.ceil(ok)
	print(ok)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Wrong Answer

Solution code:
def main():
    n,k=map(int,input().split())
    lst=sorted(list(map(int,input().split())))
    
    left=0
    right=lst[-1]
    while right-left>1:
        mid=(right+left)//2
        sm=0
        for x in lst:
            sm+=x//mid
        
        if sm<=k:
            right=mid
        else : left=mid
    print(right)

main()

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
L=list(map(int,input().split()))
    
if K>10**7:
    MAX=10**9
    MIN=0
    for i in range(100):
        Mid=(MAX+MIN)/2
        cnt=0
        for j in range(N):
            cnt+=L[j]//Mid
        if cnt<K:
            MAX=Mid
        else:
            MIN=Mid
        print(cnt)
    print(Mid)
else:
    import heapq
 
    Q=[]
    for i in range(N):
        Q.append((-L[i],L[i],1))
    heapq.heapify(Q)
     
    for i in range(K):
        l,B,cnt=heapq.heappop(Q)
        heapq.heappush(Q,(-B/(cnt+1),B,cnt+1))
    #print(Q)
    #print(Q[0][0])
     
    import math
    ans=-Q[0][0]
    print(math.ceil(ans))

Submission status: Wrong Answer

Solution code:
import sys

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

# ここは二分探索で行ける
x = max(A)
y = x

while 10000 < x:
    num = 0
    for j in range(N):
        num += (A[j] - 1) // y

    x = x // 2
    if num <= K:
        y -= x
    else:
        y += x

for i in range(y-5000, y+5000):

    num = 0
    for j in range(N):
        num += (A[j] - 1) // i

    if num <= K:
        print(i)
        sys.exit()

Submission status: Wrong Answer

Solution code:
f=lambda:[*map(int,input().split())]
n,k=f()
a=f()
a=[i*100 for i in a]
# Binary Search
def ok(x):
    c=0
    for i in a:
      c+=0--i//x
    return c<=n+k
l,r=0,10**11+1
while r-l>1:
  m=l+r>>1
  if ok(m): r=m
  else: l=m
print(l,r)
t=0--r//100
print(t-ok(t-1) if t>1 else t)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=sorted(list(map(int,input().split())))
if K==0:print(max(A));exit()

left,right=0,10**9+1
while right>left+1:
    cnt=K
    mid=(left+right)//2
    for i in range(N):
        cnt -=A[i]//mid
    if cnt>0:right=mid
    elif cnt<0:left=mid
    elif cnt==0:
        while right>left+1:
            cnt1,cnt2=K,K
            mid=(left+right)//2
            for i in range(N):
                cnt1 -=A[i]//mid
            for i in range(N):
                cnt2 -=A[i]//(mid+1)
            if cnt1==0 and cnt2==0:right=mid
            elif cnt1!=0 and cnt2!=0:left=mid
            else:break
        ans=10**10
        for i in (left,mid,right):
            cnt=K
            for j in range(N):
                cnt -=A[j]//i
            if cnt==0:
                ans=min(ans,i)
        print(ans)
        exit()

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
left=1
right=A[-1]
ans=(left+right)//2
if N==1:
    if A[0]%(K+1)==0:
        print(A[0]//(K+1))
    else:
        print(A[0]//(K+1)+1)
else:
    while 1:
        count=0
        for i in range(N)[::-1]:
            if A[i]%ans==0:
                count+=A[i]//ans-1
            else:
                count+=A[i]//ans
            if count>K:
                break
        if count<=K:
            right=ans
        else:
            left=ans
        if right-left<=1:
            break
        ans=(left+right)//2
    for i in range(N):
        if A[i]%left==0:
            count+=A[i]//left-1
        else:
            count+=A[i]//left
        if count>K:
            break
    if count==K:
        print(left)
    else:
        print(right)

Submission status: Wrong Answer

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

def check(N, K, A, L):
    return sum(a // L for a in A) <= K

lo = 1
hi = max(A)+1
while lo < hi:
    m = (lo + hi)//2
    ok = check(N, K, A, m)
    if ok: # m 出来れるのでもっと小さく切れるか
        hi=m
    else:
        lo=m+1
print(min(max(A), lo))

Submission status: Wrong Answer

Solution code:
import math
import numpy as np
a = list(map(int, input().split()))
b = list(map(int, input().split()))

for i in range(0,a[1]):
    b[np.argmax(b)] = b[np.argmax(b)] / 2

print(math.ceil(max(b)))

Submission status: Wrong Answer

Solution code:
N,K=map(int, input().split())
A=list(map(int, input().split()))
if K==0:
  print(max(A))
  exit()
def f(x):
  cnt=0
  for i in A:
    cnt+=i//x
  if cnt<=K:
    return True
  else:
    return False
ok=1
ng=1000000000
for i in range(50):
  mid=(ok+ng)//2
  if f(mid):
    ng=mid
  else:
    ok=mid
print(ng)

Submission status: Wrong Answer

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

for i in range(K):
    sa = Alst.index(max(Alst))
    Alst.append(Alst[sa]/2)
    Alst[sa] = Alst[sa]/2

print(math.ceil(max(Alst)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
xlist = []
wa = sum(a)
for i in a:
  xlist.append((k+n)*i/wa)

xlist_int = []
for i in xlist:
  j = int(i)
  if j == 0:
    j = 1
  xlist_int.append(j)

amari = n+k-sum(xlist_int)
xlist_hi = [xlist_int[i]/xlist[i] for i in range(n)]
xlist_hi.sort()
ans = math.ceil(wa/(k+n)/xlist_hi[amari])


print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
arr=list(map(int,input().split()))
if(k==0):
	print(max(arr))
else:
	low=1
	high=1000000000
	while(low<=high):
		mid=low+(high-low)//2
		if(mid==1):
			print(mid)
			break
		count=0
		count2=0
		for i in range(n):
			count+=(arr[i]-1)//mid
			count2+=(arr[i]-1)//(mid-1)
		if(count==k and count2==k+1):
			print(mid)
			break
		elif(count<k or (count==k and count2!=k+1)):
			high=mid-1
		else:
			low=mid+1

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
arr = list(map(int,input().split()))
denominator = sum(arr)

piece = [(K+N)*arr[i]//denominator+1 for i in range(N)]
value = [arr[i]/piece[i] for i in range(N)]

left = K-sum(piece)
for i in range(left):
    j = value.index(max(value))
    piece[j] += 1
    value[j] = arr[j]/piece[j]

import math
print(round(max(value)))

Submission status: Wrong Answer

Solution code:
def check(A, K, L):
    i = 0
    for a in A:
        i += a//L
        if i > K:
            return False
    return True

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort(reverse=True)
l = 0
r = A[0]
while l + 1 < r:
    m = (l+r)//2
    if check(A, K, m):
        r = m
    else:
        l = m
print(r)

Submission status: Wrong Answer

Solution code:
import math
n,d = map(int, input().split(' '))
cirs = list(map(int, input().split(' ')))

if n == 1:
  print(math.ceil(cirs[0]/(2**d)))
else:
  for _ in range(d):
    list.sort(cirs, reverse=True)
    first = cirs[0]
    if len(cirs) == cirs.count(first):
      second = cirs[1]
    else:
      second = sorted(set(cirs), reverse=True)[1]
    # firstの削除
    cirs.remove(first)
    if first/2 < second:
      cirs.extend([second, first-second])
    else:
      cirs.extend([first/2, first/2])
print(math.ceil(max(cirs)))

Submission status: Wrong Answer

Solution code:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def cc(al, v_max, k):
	for v in al:
		if v < v_max:
			return True
		k -= - (-v // v_max)-1
		#pa((k, -(-v // v_max)))
		if k < 0:
			return False
	return True
		

def main():
	#a = int(input())
	n, k = tin()
	#s = input()
	al = lin()
	al.sort(reverse = True)
	#print(al)
	ok = al[0]
	ng = 0.01
	while ok - ng > 0.01:
		mid = (ok + ng)/2
		ii=cc(al, mid, k)
		#pa((mid,ii))
		if ii:
			ok = mid
		else:
			ng = mid
	#pa(ok)
	iok = int(ok*100)
	if iok % 100 >= 10:
		iok += (100-iok%100)
	iok = iok//100
	print(iok)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Wrong Answer

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

if N > K:
    for _ in range(K):
        cut = max(A)
        A.remove(cut)
        A.append(cut / 2)
        A.append(cut / 2)
    print(int(max(A)))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import math

numbers = input().split(" ")
n = int(numbers[0])
k = int(numbers[1])

numbers = input().split(" ")

a1 = [int(x) for x in numbers]
a2 = [[i, a1[i], 0] for i in range(n)]

#a2.sort(key=lambda x: x[1])

for i in range(k):
    a2.sort(key=lambda x: x[1])
    a2[-1][1] /= 2
    a2[-1][2] += 1

a2.sort(key=lambda x: x[2])

for i in range(n):
    a1[i] /= (a2[i][2] + 1)

a1.sort()

print(math.ceil(a1[-1]))

Submission status: Wrong Answer

Solution code:
import heapq
from math import ceil

N,K = list(map(int,input().split()))
A = list(map(lambda x: -int(x),input().split()))

heaplist = []
for Ai in A:
    heapq.heappush(heaplist,(Ai,1,Ai))

if 5*10**7 < K:
    print(1)
else:
    for i in range(K):
        m = heapq.heappop(heaplist)
        heapq.heappush(heaplist,(m[2]/(m[1]+1),m[1]+1,m[2]))

# print(A)
print(ceil(-heapq.heappop(heaplist)[0]))

Submission status: Wrong Answer

Solution code:
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
n, k=  map(int, input().split())
A =list(map(int, input().split()))
s = sum(A)
X = []
for i in A:
    X.append(math.ceil(k*i/s))
    #x = round(k*i/s, 1)
    #X.append(Decimal(str(x)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
Y = []
for j in range(n):
    Y.append(A[j]/(X[j]+1))
print(math.ceil(max(Y)))
#print(X)

Submission status: Wrong Answer

Solution code:
import math

N,K = map(int, input().split())
A = list(map(int, input().split()))
epsilon = 10**(-9)
#A = [a-epsilon for a in A]

_min = 0
_max = max(A)

while _max - _min < epsilon:
  new = (_min+_max)/2
  if _min < int(new):
    new = int(new)
  times = sum([math.ceil(a/new)-1 for a in A])
  #print(_min, new, _max, times, [math.ceil(a/new)-1 for a in A])
  
  if times <= K:
    _max = new
  else:
    _min = new
  #print(_min, _max)

if  sum([math.ceil(a/_max)-1 for a in A]) <= K:
  print(math.ceil(_max))
else:
  print(math.ceil(_min))

Submission status: Wrong Answer

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

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

N, K = MI()
mylist = LI()
length = len(mylist)

high = max(mylist)+1
low = 0
mid = (high + low) / 2

while high - low >= 0.001:
    temp = 0
    for i in mylist:
        if i % mid == 0:
            temp += (i // mid) - 1
        else:
            temp += i // mid
    if temp > K:
        low = mid
    else:
        high = mid
    mid = (high + low) / 2

print(math.ceil(high))

Submission status: Wrong Answer

Solution code:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def cc(al, v_max, k):
	for v in al:
		if v < v_max:
			return True
		k -= - (-v // v_max)-1
		#pa((k, -(-v // v_max)))
		if k < 0:
			return False
	return True
		

def main():
	#a = int(input())
	n, k = tin()
	#s = input()
	al = lin()
	al.sort(reverse = True)
	#print(al)
	ok = al[0]
	ng = 0.01
	while ok - ng > 0.01:
		mid = (ok + ng)/2
		ii=cc(al, mid, k)
		#pa((mid,ii))
		if ii:
			ok = mid
		else:
			ng = mid
	#pa(ok)
	iok = int(ok*100)
	if iok % 100 >= 5:
		iok += (100-iok%100)
	iok = iok//100
	print(iok)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
arr = list(map(int,input().split()))
denominator = sum(arr)

piece = [(K+N)*arr[i]//denominator+1 for i in range(N)]
value = [arr[i]/piece[i] for i in range(N)]

left = K-sum(piece)
for i in range(left):
    j = value.index(max(value))
    piece[j] += 1
    value[j] = arr[j]/piece[j]

print(round(max(value)))

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
arr = list(map(int,input().split()))
denominator = sum(arr)

piece = [(K+N)*arr[i]//denominator+1 for i in range(N)]
print(piece)
value = [arr[i]/piece[i] for i in range(N)]

left = K-sum(piece)
for i in range(left):
    j = value.index(max(value))
    piece[j] += 1
    value[j] = arr[j]/piece[j]

print(round(max(value)))

Submission status: Wrong Answer

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

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

def check(x):
    res = 0
    for i in a:
        if not i == x:
            res += math.floor(i / x)
    return res

l = 0
r = 10 ** 9 + 1
for _ in range(40):
    x = (l + r) / 2
    if check(x) > k:
        l = x
    else:
        r = x
print(math.ceil(l))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力

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

b = a[:]
vote = [0] * n
ans = 0
for i in range(k):
    tar = b.index(max(b))
    vote[tar] += 1
    b[tar] = a[tar] / (vote[tar] + 1)

print("{}".format((int(max(b) + 0.5))))

Submission status: Wrong Answer

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

low=1
high=2*max(A)
X=max(A)
while low<=high:
  mid=(low+high)//2
  cnt = 0
  for i in range(N):
      cnt += A[i]//mid
  if K<cnt:
    low=mid+1
  else:
    X=min(X,mid)
    high=mid-1
print(X)

Submission status: Wrong Answer

Solution code:
from math import floor, ceil


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    lower = 1
    upper = a[-1] + 100
    while upper - lower >= 0.25:
        target = (lower + upper) / 2
        now = 0
        for i in range(n):
            now += ceil(a[i] / target) - 1 if a[i] % target > 0 else 0
        if now > k:
            lower = target
        else:
            upper = target
    print(ceil(lower) if k > 0 else a[-1])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
nk=input("").split(" ")
n=int(nk[0])
k=int(nk[1])
lia=input("").split(" ")
lisa=[]
for i in lia:
    lisa+=[int(i)*10000]
sa=sum(lisa)
lisf=[]
lisw=[]
t=int(sa/(k+1))
for i in lisa:
    f=(i*(k+1))%sa
    if(f==0):
        lisf+=[0]
        lisw+=[int(i*(k+1)/sa)-1]
    else:
        lisf+=[(t-f)/(int(i*(k+1)/sa)+1)]
        lisw+=[int(i*(k+1)/sa)]
    
lisf.sort()
s=k-sum(lisw)
kk=int((t-lisf[s])/10000)
if((t-lisf[s])%10000==0):
    print(kk)
else:
    print(kk+1)

Submission status: Wrong Answer

Solution code:
f=lambda:[*map(int,input().split())]
n,k=f()
a=f()
a=[i*100 for i in a]
# Binary Search
def ok(x):
    c=0
    for i in a:
      c+=0--i//x
    return c<=n+k
l,r=1,10**11+1
while r-l>1:
  m=l+r>>1
  if ok(m): r=m
  else: l=m
t=0--r//100
print(t-ok(max(1,t-1)))

Submission status: Wrong Answer

Solution code:
import math
def check(lis,k,mid):
	for i in lis:
		k-=(i//mid)
	return k>=0
n,k=map(int,input().split())
lis=list(map(int,input().split()))
a,b=1,max(lis)
ans=b
while(a<=b):
	mid=(a+b)/2
	if(check(lis,k,mid)):
		ans=mid
		b=mid-0.000001
	else:
		a=mid+0.000001
print(int(math.ceil(ans)))

Submission status: Wrong Answer

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

for i in range(K):
  v = max(A)
  i = A.index(v)
  A[i]/=2
  
print(math.ceil(max(A)))