yes you can frame this problem as a knapsack problem(but not exactly knapsack) like dp[i][j] where i states number of fruits taken and j for weight of total fruits ......but please mind it some packets of fruits are free means price[x] is equal to zero(which is violating the test limits)...hope this thing will work for you
On Sun, Dec 16, 2012 at 5:57 PM, Neolithic <[email protected]> wrote: > > Test cases of the problem are not testing this condition: > > "he will not buy more than n packets of apples." > > I got a success without putting check for this condition. > > On Saturday, 15 December 2012 19:39:34 UTC+5:30, Marti wrote: >> >> I am having trouble figuring out the reccurrence for the following on >> SPOJ which I believe is a Knapsack DP problem.Please help me. >> http://www.spoj.com/problems/**ABA12C/<http://www.spoj.com/problems/ABA12C/> >> > -- > You received this message because you are subscribed to the Google Groups > "Google Code Jam" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msg/google-code/-/9SX_6gBpceEJ. > > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
