human
Rearrange array such that sum of same indexed elements is atmost K | ''Function to rearrange array such that sum of similar indexed elements does not exceed K.
'' Sort the array B[]  in descending order.
'' If condition fails.
'' Print the array.
''Driver Code.
'' Given arrays"
How can the above be solved in Python?
 What is a code to rearrange array such that sum of same indexed elements is atmost K and the other steps required?
assistant
#Here is code to rearrange array such that sum of same indexed elements is atmost K and the other steps required.
 def rearrangeArray ( A , B , N , K ) :
	B . sort ( reverse = True )
	flag = True
	for i in range ( N ) :
		if ( A [ i ] + B [ i ] > K ) :
			flag = False
			break
	if ( flag == False ) :
		print ( " - 1" )
	else :
		for i in range ( N ) :
			print ( B [ i ] , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
	A = [ 1 , 2 , 3 , 4 , 2 ]
	B = [ 1 , 2 , 3 , 1 , 1 ]
	N = len ( A )
	K = 5 ;
	rearrangeArray ( A , B , N , K )