human
Schedule jobs so that each server gets equal load | Function to find new array a.
find sum S of both arrays a and b ..
Single element case ..
This checks whether sum s can be divided equally between all array elements . i . e . whether all elements can take equal value or not ..
Compute possible value of new array elements ..
Possibility 1.
ensuring that all elements of array b are used ..
If a ( i ) already updated to x move to next element in array a ..
Possibility 2.
Possibility 3.
Possibility 4.
If a ( i ) can not be made equal to x even after adding all possible elements from b ( i ) then print - 1..
check whether all elements of b are used ..
Return the new array element value ..
Driver Code"
How can the above be solved in Python?

What is a code to schedule jobs so that each server gets equal load and the other steps required?
assistant
#Here is code to schedule jobs so that each server gets equal load and the other steps required.
 def solve ( a , b , n ) :
	s = 0
	for i in range ( 0 , n ) :
		s += a [ i ] + b [ i ]
	if n == 1 :
		return a [ 0 ] + b [ 0 ]
	if s % n != 0 :
		return - 1
	x = s // n
	for i in range ( 0 , n ) :
		if a [ i ] > x :
			return - 1
		if i > 0 :
			a [ i ] += b [ i - 1 ]
			b [ i - 1 ] = 0
		if a [ i ] == x :
			continue
		y = a [ i ] + b [ i ]
		if i + 1 < n :
			y += b [ i + 1 ]
		if y == x :
			a [ i ] = y
			b [ i ] = 0
			if i + 1 < n : b [ i + 1 ] = 0
			continue
		if a [ i ] + b [ i ] == x :
			a [ i ] += b [ i ]
			b [ i ] = 0
			continue
		if i + 1 < n and a [ i ] + b [ i + 1 ] == x :
			a [ i ] += b [ i + 1 ]
			b [ i + 1 ] = 0
			continue
		return - 1
	for i in range ( 0 , n ) :
		if b [ i ] != 0 :
			return - 1
	return x
if __name__ == " _ _ main _ _ " :
	a = [ 6 , 14 , 21 , 1 ]
	b = [ 15 , 7 , 10 , 10 ]
	n = len ( a )
	print ( solve ( a , b , n ) )