Doubt in the problem minimum money needed

While solving the problem minimum money,i am able to pass the given test case in the question but not able to pass all the test cases of this problem .
Please help out.The code via which i am solving is

@TusHar-AroRa-2294450460870717 hey there is problem in your DP logic have corrected and commented it please check it: