March Long Challenge Question

Please review my code once and tell me why my code is not showing AC.
My approach is for every student I will choose what he will choose according to the price and number of ingredients left.
My code - CodeChef: Practical coding for everyone
Please tell me :frowning:

Your code is failing these test cases
2
6 4 11 5 1 4
6 20 11 8 3 6
Correct o/p : 16 , 29
Your o/p : 18 , 30