human
Minimum total sum from the given two arrays | Function that prints minimum sum after selecting N elements.
Initialise the dp array.
Base Case.
Adding the element of array a if previous element is also from array a.
Adding the element of array a if previous element is from array b.
Adding the element of array b if previous element is from array a with an extra penalty of integer C.
Adding the element of array b if previous element is also from array b.
Print the minimum sum.
Driver code.
Given array arr [ ].
Given cost.
Function Call"
Solution in Python:

=====
What is a code to minimum total sum from the given two arrays and the other steps required?
assistant
#Here is code to minimum total sum from the given two arrays and the other steps required.
 def minimumSum ( a , b , c , n ) :
	dp = [ [ 1e6 for i in range ( 2 ) ] for j in range ( n ) ]
	dp [ 0 ] [ 0 ] = a [ 0 ]
	dp [ 0 ] [ 1 ] = b [ 0 ]
	for i in range ( 1 , n ) :
		dp [ i ] [ 0 ] = min ( dp [ i ] [ 0 ] , dp [ i - 1 ] [ 0 ] + a [ i ] )
		dp [ i ] [ 0 ] = min ( dp [ i ] [ 0 ] , dp [ i - 1 ] [ 1 ] + a [ i ] + c )
		dp [ i ] [ 1 ] = min ( dp [ i ] [ 1 ] , dp [ i - 1 ] [ 0 ] + b [ i ] + c )
		dp [ i ] [ 1 ] = min ( dp [ i ] [ 1 ] , dp [ i - 1 ] [ 1 ] + b [ i ] )
	print ( min ( dp [ n - 1 ] [ 0 ] , dp [ n - 1 ] [ 1 ] ) )
if __name__ == ' _ _ main _ _ ' :
	arr1 = [ 7 , 6 , 18 , 6 , 16 , 18 , 1 , 17 , 17 ]
	arr2 = [ 6 , 9 , 3 , 10 , 9 , 1 , 10 , 1 , 5 ]
	C = 2
	N = len ( arr1 )
	minimumSum ( arr1 , arr2 , C , N )