Hello everyone. I was doing the problem Dima and Salad http://codeforces.me/problemset/problem/366/C and this is the recursive memoized solution that I came up with
rec(int tasteNow, int caloriesNow, int index)
so from here we can go to index+1 choosing fruit at index or index+1 without choosing fruit at index
rec(int tasteNow, int caloriesNow, int index) { if (tasteNow/caloriesNow) == k dptaste[index] = Math.max(dptaste[index], tasteNow) res = Math.max(rec(tasteNow+taste[index],caloriesNow+calories[index],index+1), rec(tasteNow, caloriesNow, index+1) dptaste[index] = Math.max(dptaste[index], res)
Can someone tell me what is wrong with my approach and how I can modify it to get the correct solution. Thanks



