Company: opentext_16oct
Difficulty: medium
Product Selection for Maximum Energy Problem Description Tom is running an experiment and may pick any subset of N products. Product i has an energy energy[i] , a weight weight[i] and a maker company[i] : company[i] = 0 means the product comes from Reds Ltd. Such a product works on its own and can be picked freely. company[i] = 1 means the product comes from Blues Ltd. Such a product does not work alone: it may be picked only if at least one other Blues Ltd. product is picked as well. So a selection is valid when the total weight of the picked products is at most W and the number of picked Blues Ltd. products is not exactly 1 (it is 0 , or 2 or more). Find the largest total energy of a valid selection. Picking nothing is valid and gives energy 0 , so print 0 when no product can be used. (inferred -- the source does not say what to print when nothing fits; the empty selection with energy 0 is used.) Function Description Complete the function solve in the editor with the following parame