MIXTURES(SPOJ)(Dp)

code:https://ide.codingblocks.com/#/s/16606
ques:https://online.codingblocks.com/player/1972/content/901
My approach is naive but can it be converted to top down dp i am confused between which parameters to take,first is definitely array size the second one I am not able to figure out.
currently, my solution is passing 3 out of test cases and for rest other TLE.

As you are calling recursive funiton in everY iteration it will get you TLE so try to use DP approach it wll be very efficient .
By the way, M giving you the DP code for this pb if you wanna help you can go through this
https://ide.codingblocks.com/#/s/16994