Problem A. Ascending Rating

HDU - 6319