Skip to content

Instantly share code, notes, and snippets.

You have a length of timber that needs to be cut into several pieces. The points where the cuts have to be made are marked on the timber, measured from one end. The only precision cutting company available at short notice charges, for each cut, a rate in dollars equal to the length of the piece in metres before cutting.
![Task 5](https://cgi.cse.unsw.edu.au/~progcomp/2014/open/task5img.png)
The order in which the cuts occur affects the total price. For example, a piece 10m long with cuts needed at 4m, 5m and 7m could be cut first at 5m, costing $10, leaving two 5m sections requiring one cut each, a total of $10 + $5 + $5 = $20.
However if the cuts are made at 4m, 7m and 5m the total cost is $10 + $6 + $3 = $19.
# Your Task
Write a program that determines the optimal cutting cost for a piece of timber with up to 50 cuts, and, for maximum marks, the optimal cutting sequence. The cost is to be expressed to the nearest cent, as cuts need not be integral.
body {
background: #F0F0F0 !important;
}
#top-panel {
height: 37px !important;
background: #036;
}
#top-panel td #login-field span a {