Computer Science, asked by shahvraj225, 8 months ago

arnold is planning to follow a diet suggested by his Nutritionist. The Nutritionist prescribed him the total protein, carbohydrates and fats, he should take daily. Arnold searches on an online food store and makes a list of protein, carbohydrates and fats contained in a single unit of various food items.
How much units of each food item should he consume to maximize the presceibed values.
Input
first line maximum xPyCzF where P C F are protein carbohydrate and fats
second line nutrients of food item.Food itms are seperated by ' | ' in input

Output
minimum shortfall
Example
input
100P 130C 130F
10P 20C 30F|20P 30C 20F

output
20 0 10

Explaination
having 2 units of item A and 3 units of item B provides
2*[10P 20C 30F]+3[20P 30C 20F] = 80P,130C,120F. This is the best combination since shortfall is minimum ie (20 0 10).
If 3*[10P 20C 30F]+2*[20P 30C 20F] = 70P,120c,130F . the shortfall is 30P 10C 0F here shortfall of Protein is more than previous.

Example 2
Input
130P 120C 110F
4P 9C 2F|4p 3C 2F|7P 1C 3F
Output
2 4 50
explaination
Having 9 units of itemA ,9 units of item B and 8 units of item C gives
9*[4P 9C 2F]+9*[4p 3C 2F]+8*[7P 1C 3F]=128P,116C,60F. This is best combination that can reduce shortfall[2P 4C 50F] witout execeeding prescription.

Answers

Answered by AllenCourleon
0

Answer:

What is your question ....

I can't understand your question....

Answered by rajkumarh75
1

Answer:

pls ask questions one by one please......

Similar questions