human
Maximum length of all possible K equal length ropes generated by cutting N ropes | Function to find the maximum size of ropes having frequency at least K by cutting the given ropes.
Stores the left and the right boundaries.
Stores the maximum length of rope possible.
Iterate while low is less than or equal to high.
Stores the mid value of the range [ low , high ].
Stores the count of ropes of length mid.
Traverse the array arr [ ].
If count is at least K.
Assign mid to ans.
Update the value of low.
Otherwise , update the value of high.
Return the value of ans.
Driver Code"
Solution in Python:
 ... What is a code to maximum length of all possible K equal length ropes generated by cutting N ropes and the other steps required?
assistant
#Here is code to maximum length of all possible K equal length ropes generated by cutting N ropes and the other steps required.
 def maximumSize ( a , k ) :
	low = 1
	high = max ( a )
	ans = - 1
	while ( low <= high ) :
		mid = low + ( high - low ) // 2
		count = 0
		for c in range ( len ( a ) ) :
			count += a // mid
		if ( count >= k ) :
			ans = mid
			low = mid + 1
		else :
			high = mid - 1
	return ans
if __name__ == ' _ _ main _ _ ' :
	arr = [ 1 , 2 , 3 , 4 , 9 ]
	K = 6
	print ( maximumSize ( arr , K ) )