Comments
+1

Although I doubt that DP is the best technique for that problem, you may want to make the hashCode() method of the Key class depend on its array (foodAmounts) attribute. One way to to do is to return Arrays.hashCode(foodAmounts) which should practically return a unique hashes for unique arrays (same length and elements).

Just do the normal brute force recursion 2^n*2^n*n (memoize in a map if u want) compute the answer offline for all 1<=n<=15 and u will get a similar array with the actual answers. I believe that the array u presented doesn't account for the factorial thing so u should account for it somehow before u print the answer.

complexity of kmp is O(length(str1)+length(str2)) i.e. 100000+1000 for every string ,and multiply this by 100 (number of strings) so you get about 10 million operation which is pretty fast to pass

On mostafa_fahim → Submission Error, 15 years ago
0

I think every thing is ok now,

On mostafa_fahim → Submission Error, 15 years ago
+3

no , um using java

About Task C 
for this input 
1 1 2 2
a
b: a 2
c: a 1
1 a
1 a                                                                                                    

I am printing 

1
b 1

while the answer is

1
c 2

I can't see why my output is wrong (I think both outputs are correct in this case)