Graph Problem Minimizing Cost

https://cses.fi/problemset/task/1686

Can I get some hints to solve this problem, I thought of Dynamic Programming but this Graph is not a DAG.