A shoemaker has N jobs ordered by customers waiting in his shop. He works on one job at a time, and job i takes Ti days to finish. Ti is an integer with 1≤Ti≤1000.
For every day that passes before job i starts, the shoemaker pays a fine of Si cents. Si is an integer with 1≤Si≤10000. Find the job order that makes the total fine as small as possible.
Once an order is fixed, job i starts after a delay equal to the sum of the durations of the jobs placed before it. The total fine is the sum, over all jobs, of that delay multiplied by Si.
The shoemaker cannot run two jobs on the same day. After he starts job i, he cannot work on any other job until job i is finished.