Unable to get the logic?

I am trying to solve this problem SPOJ.com - Problem PRATA but unable to get the logic,I seen the comments some solved it using binary search and min-heap any one help me :slight_smile: