Codesprint - Working with boxes Modification

Original Problem

After an update

 If the operation time < 0 at any point of time, the the time taken is 0.

I misinterpreted the problem as to resetting the total operation time to 0 when it goes negative. i.e, now order of operations matters even more.

For example, (1 1 2 2) with C = 3,

1*1 + 1*1 - 3 = -1
Total Time = -1 -> 0
2*1 + 2*1 - 3 = 1
Total Time = 0+1 = 1
....

Or in other order

2*1 + 2*1 - 3 = 1
Total Time = 1
1*1 + 1*1 - 3 = -1
Total Time = 1-1 = 0
....

Any ideas on this interpretation of the problem?

//