How to solve a DP problem that minimizes a sum of cubic powers?
The essence of the dynamic programming is to recognize the appropriate subproblems.
Here is a way to formulate the subproblems. Let us compute $dp[i]$, the minimum total waste for weight sequence $w_{i}, w_{i+}, \cdots, w_N$, where $1\le i\lt N$. The wanted minimum total waste of the entire sequence shall be $dp[1]$.
The base cases are $dp[N]=dp[N-1]=\cdots=0$, where $dp[i]=0$ as long as $w_{i} + w_{i+1}+ \cdots+w_{N}\le M$ since the last trip does not produce waste. Let $j$ be the smallest such index.
What about $dp[j-1]$, $dp[j-2]$ and beyond? We note that $dp[k]$ is the minimum of
$$\begin{align}
  dp[k+1] &amp;+ (M-w_k)^3,\\ 
  dp[k+2] &amp;+ (M-(w_k+w_{k+1}))^3,\\
  \cdots\\
  dp[k+t] &amp;+ (M-(w_k+w_{k+1}+\cdots+w_{k+t-1}))^3\\
  \cdots,\\
  \end{align}$$
where the list goes on as long as $w_k+w_{k+1}+\cdots+w_{k+t-1}\le M$.
This recurrence relation enables us to compute $dp[k-1]$ if $dp[k], dp[k-1], \cdots, dp[N]$ are known.
The time complexity of algorithm is about $O(N*N)$.
Java code

The above is an implementation in Java that takes file &quot;elevate.in&quot; as input. Just click &quot;run&quot; to see the result.
Exercises
Here are two exercises based on the same situation to think about.
Exercise 1. (One minute or two.) Suppose the total waste is defined as $$TW=\sum_{t=2}^{S}(WF[t])^3$$ instead. Note that the WF of the first strip instead of the last strip is excluded.
Exercise 2. Suppose the total waste is defined as $$TW=\sum_{t=2}^{S-1}(WF[t])^3$$ instead. Note both the WF of the first strip and the last strip are excluded.