how to solve this question with binary search and priority queue?

help
binary-search
easy
priority
queue

#1

Please Explain your approach in detail
Problem Link-link text