Dynamic Programming

Hi, so I recently started to do DP, but I am not getting the hang of it. I am doing all of the easy problems in the USACO Gold DP section, but I am still having a lot of difficulty. When solving DP problems, I usually get the idea of how to implement DP, but I never do it properly. I have yet to implement a DP problem on my own. Do you guys have any tips on how to properly implement DP? Also, I read online that the only way to get better at DP problems is to practice them. So, can you guys give me some DP problem sets? Preferably from beginner to advanced. Thanks!!

Have you tried the CSES DP problem set?

I finished all the easy problems in that. I want to do the hard problems once I can solve easy dp problems

When solving DP problems, I usually get the idea of how to implement DP, but I never do it properly.

Could you give an example?

Like for this problem, https://usaco.guide/gold/knapsack#problem-usaco-574, I knew that I had to keep a dp[2][t]. I knew the first one kept track of cases without halving her fullness and another one keeping track with halving. However, I implemented it wrong and I had to look at the solution.

Yeah, it was like that for me was well when I started out with DP as well. The only solution I can give is just like what that website said: practice. You can get alot of DP problems on codeforces I think.

Ok thanks! :grinning: