https://www.codechef.com/FFC22019/problems/FFC219G

pls share the approaches

Can be solved with Basic DP.

Let dp[i] = solution of the array for 1 to i positions i.e. first i elements.

Recurrence relation

dp[i] = max[dp[j]+sum(j, j-1 + (i-j+1)/2)] such that j<i and length[j,i] = even

Base Case: dp[0] = 0;

1 Like

pls elaborate a little with further explanation