ajraj27's blog

By ajraj27, history, 10 months ago, In English

There are N food items lined up in a store. Given the nutritional value and weights of each of them, you need to buy a set of these food items such that they do not exceed the capacity of your carrying bag W and the overall sum of the nutritional value of the bought items is maximized. You can assume that you have enough money to buy all of these items. Also, you have 2 magic potions, using which you can increase the nutrition value of any two distinct food items by certain factors. That is, given two integers X and Y, you can choose any two distinct food items and multiply their nutritional value by a factor of X and Y respectively. The magic potion does not affect the weight of the items. Now, find the maximum sum of nutritional values that you can buy, given the weight constraint.

Input: 1 1 2 3 4 2 6

Output: 16

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it