Hello everyone, I am trying this DP problem on my own, I am using Memoization. Most of the test cases work fine, but I don't know why I am getting a wrong answer. Can anyone please point out my mistake? Also this is my first time posting here, so if I make any mistake, I apologise in advance.
Problem link — https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=977) my code — https://pastebin.com/LddwmQRc








Well, what if the value of
nwill be less than the value ofk? Some of yourdp[i]states will still be true.I don't follow, can you suggest a test case?
As T1mka said, in the problem bounds it is possible that N < K (if N is less than 100).