human
Maximum sum of values of N items in 0 | Function to find the maximum value.
base condition.
K elements already reduced to half of their weight.
Dont include item.
If weight of the item is less than or equal to the remaining weight then include the item.
Return the maximum of both cases.
If the weight reduction to half is possible.
Skip the item.
Include item with full weight if weight of the item is less than the remaining weight.
Include item with half weight if half weight of the item is less than the remaining weight.
Return the maximum of all 3 cases.
Driver Code"
Solution in Python:

What is a code to maximum sum of values of N items in 0 and the other steps required?
assistant
#Here is code to maximum sum of values of N items in 0 and the other steps required.
 def maximum ( value , weight , weight1 , flag , K , index , val_len ) :
	if ( index >= val_len ) :
		return 0
	if ( flag == K ) :
		skip = maximum ( value , weight , weight1 , flag , K , index + 1 , val_len )
		full = 0
		if ( weight [ index ] <= weight1 ) :
			full = value [ index ] + maximum ( value , weight , weight1 - weight [ index ] , flag , K , index + 1 , val_len )
		return max ( full , skip )
	else :
		skip = maximum ( value , weight , weight1 , flag , K , index + 1 , val_len )
		full = 0
		half = 0
		if ( weight [ index ] <= weight1 ) :
			full = value [ index ] + maximum ( value , weight , weight1 - weight [ index ] , flag , K , index + 1 , val_len )
		if ( weight [ index ] / 2 <= weight1 ) :
			half = value [ index ] + maximum ( value , weight , weight1 - weight [ index ] / 2 , flag , K , index + 1 , val_len )
		return max ( full , max ( skip , half ) )
value = [ 17 , 20 , 10 , 15 ]
weight = [ 4 , 2 , 7 , 5 ]
K = 1
W = 4
val_len = len ( value )
print ( maximum ( value , weight , W , 0 , K , 0 , val_len ) )