Maximum Weight Difference -- Wrong Answer

Hi,
I am getting wrong answer.My solution is http://www.codechef.com/viewsolution/4485008.
Please help

Thank you :slight_smile:

//