class Solution:
"""
@param L: Given n pieces of wood with length L[i]
@param k: An integer
@return: The maximum length of the small pieces
"""
def woodCut(self, L, k):
if sum(L)<k or not L:
return 0
l = 1
r = max(L)
size = len(L)
while l <= r:
mid = l + (r-l)//2
if self.cnt(L,mid) < k:
r = mid - 1
elif self.cnt(L,mid) == k:
l = mid +1
elif self.cnt(L,mid) > k:
l = mid +1
return r if self.cnt(L,r) >= k and r<= max(L) else 0
def cnt(self,L,cut):
cnt = 0
for l in L:
cnt += l//cut
return cnt