Wine problem doubt

while making table for bottom up approach in video, We are considering that dp[1][2] was representing max profit at day 4,5 by selling bottle value 2 and 3, and dp[2][3] was representing max profit at day 4,5 by selling bottle values 3,5. dp[1][3] represents max profit at days 3,4,5 by selling bottles values 2,3,5.
Here we are considering 2 cases, either profit of bottle value 5 at 3rd day and profit of bottle values 2,3 at days 4,5 or profit of bottle value 2 at 3rd day and profit of bottle values 3,5 at 4,5 day.
my question is why we are not considering any case where bottle value 3 is sold at 3rd day and bottle value 2,5 at 4,5 days?

Can u mention problem link and video link (with timestamp)

cpp video- dynamic programming, wine problem at time 29:07
link - https://youtu.be/eSDa4iauLbo?t=1747

Dp table shows the optimal values at every point.
We are considering the bottle 3 at day 3 when dp[1][3] is being solved for bottles 2,3,5 for day 3,4,5
bt it can be seen that answer cant not become maximum by considering bottle 3 at day 3 .So u are not able to see it in the solution.

For bottle 2 and 5 at day 4 and 5 . There is not any possible combination when u get have these two bottles at position 4 and 5 because u can only pick bottle from exteame points.

Hope u get it. Hit like if u get it .

1 Like