Tillling problem

pls provide the solution of this problem . i am unable to approach it.

@agarwalbhavya06 hey bhavya did you have idea about dynamic programming ?

no i don’t have any idea till now.
@jaiskid
does this ques make use of dynamic programming?

@agarwalbhavya06 yes offcourse this question need a dynamic approach .

so why is tilling prob given before teaching that in course sequence??
or they should tell that DP is to be used in it
okay then i will solve it after studying DP

@agarwalbhavya06 bhavya okay please take a shot to this question and if you have any doubt please do tag