human
Maximize sum possible from an array by jumps of length i + K * arr [ i ] from any ith index | Function to find the maximum sum possible by jumps of length i + K * arr [ i ] from any i - th index.
Initialize an array dp [ ].
Stores the maximum sum.
Iterate over the range [ N - 1 , 0 ].
If length of the jump exceeds N.
Set dp [ i ] as arr [ i ].
Otherwise , update dp [ i ] as sum of dp [ i + K * arr [ i ] ] and arr [ i ].
Update the overall maximum sum.
Print the answer.
Driver Code"
Solution in Python:
 ... What is a code to maximize sum possible from an array by jumps of length i + K * arr [ i ] from any ith index and the other steps required?
assistant
#Here is code to maximize sum possible from an array by jumps of length i + K * arr [ i ] from any ith index and the other steps required.
 def maxSum ( arr , N , K ) :
	dp = [ 0 for i in range ( N + 2 ) ]
	maxval = 0
	i = N - 1
	while ( i >= 0 ) :
		if ( ( i + K * arr [ i ] ) >= N ) :
			dp [ i ] = arr [ i ]
		else :
			dp [ i ] = dp [ i + K * arr [ i ] ] + arr [ i ]
		maxval = max ( maxval , dp [ i ] )
		i -= 1
	print ( maxval )
if __name__ == ' _ _ main _ _ ' :
	arr = [ 2 , 1 , 3 , 1 , 2 ]
	N = len ( arr )
	K = 3
	maxSum ( arr , N , K )