Learning Greedy !

I am trying to learn greedy and so i am solving some problems./
I have tried to code Greedy for http://www.codechef.com/problems/FGFS ,But getting wrong answer.
Can anyone tell why?
My solution is http://www.codechef.com/status/FGFS,vippu95

//