SRM 547 - Div2 - 500 - PillarsDivTwo

I am trying to solve the following problem - TopCoder Statistics - Problem Statement
using the dynamic programming approach, and I have written down the following code to solve the problem, but unfortunately it fails on a couple of test cases when I run the practice tests in the practice room, can anybody point out the flaw in my approach to solving this problem or suggest a tweak if there is any error in coding. I have commented the code at appropriate places to make the approach clear. Here is the link to the topcoder forum for the same problem - Auth0

this link will help in dp approach :slight_smile: