Optimization problem where penalty is sensitive to permutation
I will outline two different solution methods.  Either one will work -- pick whichever one you find easiest to understand and implement.

Dynamic programming

This can be solved using dynamic programming.  We'll fill in a one-dimensional table, so that $T[s]$ stores the penalty of the best (lowest-penalty) way to obtain a sum of exactly $s$.  Once we've filled in all of the entries, $T[20]$ will tell you the lowest penalty achievable for any combination that sums to 20.

So how do we fill in the table entries?  We can fill them in recursively:

$$T[s] = \min(T[s-1]+p(s-1,1), T[s-2]+p(s-2,2), \dots, T[s-5]+p(s-5,5))$$

where $p(s,k)$ is the penalty for adding the number $k$ when the intermediate sum is $s$.  In the question, you tell us that $p(s,k) = k$ for $0 \le s &lt; 2$, $p(s,k) = 2k$ for $2 \le s &lt; 6$, etc.

Also, we have the base cases $T[0] = 0$.  As a convention, we'll agree that $T[-1]=T[-2]=T[-3]=T[-4]=\infty$.  Then you can fill in $T[1],T[2],\dots,T[20]$ in that order, using the recursive formula above.

This will give you the penalty of the best way to achieve the sum $20$.  If you also want to output the specific combination that achieves that penalty, you can keep track of that with a small modification.  Basically, each time you fill in a $T[i]$ entry with some penalty value, on the side keep track of the combination that led to that penalty value.

Graph search

Construct a weighted directed graph, with vertices 0, 1, 2, .., 20.  Each vertex corresponds to a possible intermediate sum.  From each vertex (intermediate sum) $s$, add five outgoing edges, corresponding to the five possibilities for the number you add.  The length of the edge from $s$ to $s+i$ (for $i=1,2,\dots,5$) is the penalty for adding $i$ to an intermediate sum $s$, according to the rules described in your question.

Now find the shortest path from vertex 0 to vertex 20 in this graph.  That path will correspond to a combination of values that sum to 20, and the total length of that path will correspond to the penalty of that path.  The shortest path will correspond to the combination with lowest penalty.  You can use any standard algorithm for computing shortest paths in a graph, such as Dijkstra's algorithm.