dynamic programming exercise on cutting strings
The basic idea is: Try out all cut positions as first choice, solve the respective parts recursively, add the cost and choose the minimum.

In formula:

$\qquad \displaystyle \operatorname{mino}(s, C) = 
  \begin{cases} 
    |s| &amp;, |C| = 1 \\
    |s| + \min_{c \in C} \left[ \begin{align}&amp;\operatorname{mino}(s_{1,c}, \{c' \in C \mid c' &lt; c\})\ \\ +\ &amp;\operatorname{mino}(s_{c+1,|s|}, \{c' - c \in C \mid c' &gt; c\}) \end{align}\right] &amp;, \text{ else}
  \end{cases}$

Note that applying memoisation to this recursion actually saves work as switching the order of any successively applied pair of cuts results in the same three subproblems being solved.