Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please write code in c++ to find the minimum amount of a calories for laila, the sample input and output in the first photo Find
please write code in c++ to find the minimum amount of a calories for laila, the sample input and output in the first photo
Find the minimum amount of calories needed by Laila to finish the N days of the diet. Input Format line #1 is N (days of diet) line \#2 is the calories associated with each Carbohydrates meals (array of N integer values) line \#3 is the calories associated with each Protein meal (array of N integer values) line \#4 is the calories associated with each V \& A meal (array of N integer values) Constraints all integers Output Format N ( integer: minimum calories for the N deit days.) Sample Input 0 5345681091084762312 Sample Output 0 25 Laila loves food. However, she is currently on a diet. The nutrition specialist put her on a special diet in which she eats only one meal per day! Her meal must belong to one of the following three types: (i) Carbohydrates. (ii) Protein and (iii) V\&A (Vitamins and Minerals). Whenever she eats a certain meal she gains a certain amount of calories. Different meals result in different calories depending on the day and depending on the type. For example when eating meal no. I in the Carbohydrates type, Laila gains a different amount of calories compared to eating meal no. 1 in the Protein type. Also when eating meal no. 1 in the Carbohydrates type, Laila gains a different amount of calories compared to meal no. 2 or meal no. 3 from the Carbohydrates category and so on. The diet is designed to last N days (from day 1 to day N ). Each day Laila can choose any meal she likes from any of the 3 types, however, she is not allowed to select two meals of the same type in two consecutive days. Also, if Laila selects a certain meal, she is not allowed to select the same meal again. Find the minimum amount of calories needed by Laila to finish the N days of the diet. Here is a reminder of the outline of your solution: Part1: Divide \& Conquer 1- Define the value returned by the function f which we want to optimize. 2- Define the parameters which f depends on. 3-Draw the recursion tree for f using the values from the example above. 4- Write the recursive (divide and conquer) code to solve theStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started