Maximum bullets DP

I am getting correct answer on the sample test case but not on random inputs. I have used the DP method. Is there something wrong with my approach?