human
Reduce sum of same | Function to check if elements of B can be rearranged such that A [ i ] + B [ i ] <= X.
Checks the given condition.
Sort A in ascending order.
Sort B in descending order.
Traverse the arrays A and B.
If A [ i ] + B [ i ] exceeds X.
Rearrangement not possible , set flag to false.
If flag is true.
Otherwise.
Driver Code.
Function Call"
Solution in Python:
assistant
#Here is code to reduce sum of same and the other steps required.
 def rearrange ( A , B , N , X ) :
	flag = True
	A = sorted ( A )
	B = sorted ( B ) [ : : - 1 ]
	for i in range ( N ) :
		if ( A [ i ] + B [ i ] > X ) :
			flag = False
			break
	if ( flag ) :
		print ( " Yes " )
	else :
		print ( " No " )
if __name__ == ' _ _ main _ _ ' :
	A = [ 1 , 2 , 3 ]
	B = [ 1 , 1 , 2 ]
	X = 4
	N = len ( A )
	rearrange ( A , B , N , X )