This problem is in Contest(s) below:
Contest 1396:小朋友做单调队列
Contest 1106:优先队列,树,堆