Sir, can not we use vectors for solving the hostel visit problem instead of using priority queue ?
We will take vectors for storing distance and then we will sort it by using sort() function. vectors will allow us to access the elements directly which we can not do in priority queue.