@Author : A good problem with a clear, detailed explanation. Thank you.
I was a little confused with this problem, it makes me slightly take some time, this appears to be the problem of finding the shortest path but eh
For people finding some difficulty in understanding , try solving this question
https://www.geeksforgeeks.org/dynamic-programming-set-34-assembly-line-scheduling/.
The above question adheres to the same logic.