This problem is in Contest(s) below:
Contest 1003:树与堆
Contest 1106:优先队列,树,堆