human
Minimum number of coins to be collected per hour to empty N piles in at most H hours | Function to find the minimum number of coins to be collected per hour to empty N piles in H hours.
Stores the minimum coins to be removed per hour.
Find the maximum array element.
Perform Binary Search.
Store the mid value of the range in K.
Find the total time taken to empty N piles by removing K coins per hour.
If total time does not exceed H.
Otherwise.
Prthe required result.
Driver Code.
Function Call"
Solution in Python:
 ... Write me a code to minimum number of coins to be collected per hour to empty N piles in at most H hours and the other steps required?
assistant
#Here is code to minimum number of coins to be collected per hour to empty N piles in at most H hours and the other steps required.
 def minCollectingSpeed ( piles , H ) :
	ans = - 1
	low = 1
	high = max ( piles )
	while ( low <= high ) :
		K = low + ( high - low ) // 2
		time = 0
		for ai in piles :
		time += ( ai + K - 1 ) // K
		if ( time <= H ) :
			ans = K
			high = K - 1
		else :
			low = K + 1
	print ( ans )
if __name__ == ' _ _ main _ _ ' :
	arr = [ 3 , 6 , 7 , 11 ]
	H = 8
	minCollectingSpeed ( arr , H )