Need Help in solving this kind of problems

I just started coding and practiced Dyanmic programming and graphs . But I’m not able solve this kind of problems
could anyone help me how to solve this? and if possible please share resources where I can find these type of questions;
i think this we have to use dynamic programming on graphs . can anyone share that resources if possible?