First forget about S (i). In any case, you complete all the tasks in which you receive all the rewards.
Secondly, it makes no sense to interrupt the task and switch to another. Suppose you have tasks A and B. The conclusion you get for the one that ends last is the same (it will take T (A) + T (B) to finish it, no matter how you plan) . The deduction for another job can only increase if you switch, because it will take longer to complete it. Therefore, it is best if you release the switch.
Now the problem is to order tasks in order to get the minimum amount of the fine. I'm not sure what next. You can choose the first job to minimize T (x) * sum (d) (since you are doing the dong x job, everything will delay the delay T (x)). Or you can choose the last job, since you know that you are going to pay the amount (T) * d (x) (you know when it will end). One says the order through T (x) the other says order d (x), and they are both wrong.
Probably the solution is some dynamic programming in this space, but it eludes me at the moment.
Sorin source share