Uh ... basically I'm now stuck at this problem : (problem's name, cus there are 3 in that pdf file) Candy Machine. I've solved only the second subtask (n <= 8000) so I looked for full solution (which can be found here (but hey you don't need to read it to understand my question. I'm saying this just in case you want to solve the problem your self. You can submit it by this link)). So while reading the full solution, I notice that subtask 1 (n <= 85, w <= 4) can be solved using DP over the wagon positions, and the problem is ... I can't do it. Pls kindly help me with the DP part. (Though I solved subtask 2, I'm just very eager to improve my DP skill, which obviously need some fixes ...)

Just to clarify : pls show me how to solve subtask 1 (n <= 85, w <= 4) using DP. Have a good day ^_^ !!

Uh ... 21h passed and I wonder if the question was too easy and no one care but pls, I need help. Any hint will be appreciated.