Mixtures.Spoj another approach

check this is this is correct approach
donot consider time limit just check the concept

Plz mention the algo you have followed in your code, since i am not able to understand it well.

mam i am using algo used in wine problem

Yes, your code seems fine, but it wont work for all possible testcases.