This problem is in Contest(s) below:
Contest 1003:树与堆
Contest 1106:优先队列,树,堆
Contest 1279:dp入门
Contest 1465:Dp入门