Need help with Cutting Recipes

So I am practicing and I get a WA. I tried to figure out where my code fails but to no avail.
My Code: https://www.codechef.com/viewsolution/28509204
Someone’s AC Code: https://www.codechef.com/viewsolution/28514053

I generated multiple test cases and tested them against them. Both the codes yield the same output.

I know its probably something stupidly basic that am missing.

Consider the testcase:

1
7
128 452 144 44 148 360 244

Edit:

Even simpler one:

1
3
20 10 5
1 Like

Thank you. @ssjgz

1 Like