Sichuan University Programming Contest 2011 Preliminary(for Non-SCUers)

D: Sawthooth II