solve 488 div2 500point problem.