Donkey thinks potato chips are the best food ever!
So today, when he decides to go on a long journey, he wants his backpack filled with all kinds of potato chips. He searches through the snack zone in his home and finds lots of potato chips.
To better decide which bags of potato chips to bring with him (a subset of the total bags, possibly none of them), he defines the property of a bag of chips as follows:
-
hi. The happiness this bag of chips can give to Donkey.
-
si. The space this bag of chips occupies.
-
di. The delicacy of this bag of chips.
For simplicity, we note hi,si,di as the "happiness", "space" and "delicacy" of the bag.
The total occupied space of the chosen bags can't exceed the volume of the backpack, which is
V.
However, the unoccupied space may cause bumps when Donkey moves during the journey, which further causes value loss. If the chosen chips are i1,i2,…,ik (k≥1) and the unoccupied space is U, the total value loss on account of bumps is (di1+di2+⋯+dik)×U. If you choose no bag of chips, the value loss is 0.
Considering both the advantages and disadvantages of bringing chips, the value of the whole backpack is the sum of happiness brought by these bags of chips minus the value loss. Donkey wants to maximize this value, but just can't make the decision. Help is needed for this!