INOI 2017 Problem 2 - Training
Here is how I would approach it. Yes, dynamic programming is a way to solve this problem efficiently. 

A few notations to note before hand :


prefix[k] = sum of all terms from 0 to k ( k included ).
best[k] = max possible XV till term k ( k included )


Algorithm :

 1. prefix[0] = A[i];
 2. best[0] = cubed sum A[i]

 for array A:
    // max ( m,n ) --&gt; max of m and n.
    3. best[i] = max ( cubed sum (prefix[i-1] + A[i]), best[i-1] * A[i]);

 return best[n]. n --&gt; size of array.


In other words, you choose the max value of either including the current strength into sum or by competing.