DYNAMIC PROGRAMMING DOUBT

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

Someone please help me out.
I request team coding blocks to help me in this question.