spoj question

I am trying to solve SPOJ.com - Problem MIXTURES
but getting wa. I tried numerous cases given in forum as well as comments all are correct but still wa…
link to solution W7Oz40 - Online C++ Compiler & Debugging Tool - Ideone.com

Google the question dude…anyways here’s a very good explanation answer
You can even use this