Editorial for TLE '16 Contest 6 (Mock CCC) J5 - Meal Plan
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
We can make a 2-dimensional integer array
To start off, we know that the first meal must be breakfast, so we scroll through the breakfast options and add
Scrolling through the array, as we get to
- For each lunch option, we add
to , since the student's next meal after breakfast must be lunch; - Similarly, as we get to
, then for each dinner option, we add to , since the student's next meal after breakfast must be dinner; - Lastly, as we get to
, then for each breakfast option, we add to , since after breakfast, the student can then begin considering the next day's breakfast.
In the end, we can find the number of ways to pay the most by taking the highest value of
Time Complexity:
Comments