Help with code and Runtime error - Fit To Play

I would like some help with my PHP code for the problem Fit To Play, I think I am getting the correct answers. Please view my solution here www.codechef.com/viewsolution/1289591 . What am I doing wrong?

//