Coder Ratings Wa

problem : http://www.spoj.com/problems/RATING/
solution: http://ideone.com/lvx3BP

I have been trying really hard to get this ac but failed Plz help
I am using segmented tree to make a kind of priority queue sorting the best over the other
and then storing the wins in dp
plz help