Wrong answer Delicious Dishes

http://www.codechef.com/viewsolution/4271176
I made this submission and first I got a NZEC error and I included my code in try catch block and now I get wrong answer output whereas the answers I get on test run are perfectly right.Can somebody please help me figure out the problem?

//