Dear All,

I would appreciated if anyone could give me advice about how to solve this problem in C:

1) An integer list of values (lengths of needed pieces) is entered at the input. For example: 4, 7, 6, 3
2) The length of the log is the sum of these values ( 20 in this example )
3) The log has to be cutted into pieces above.
4) The algorithm has to count the lowest possible price of cutting the log. The price of cutting is equal to the length of the log being cutted. It means that if I am cutting the log 20, I have to pay 20. The whole price is sum of all "payments". In the example above, the price is 40.

I was thinking that the list should be saved into an array and after that some kind of sorting algorithm will itterated through the list, but I have not been able to solve this problem so far. Thank you for your hints.