Hostel Visits Heaps

I am getting TLE in second test case, can you tell how to overcome this? My code is : https://ide.codingblocks.com/s/235678

hi @gourav
you have pass priority queue in function by value hence it copies whole priority every time
so this will definitely give TLE

if you pass it by reference then also it will give TLE
as now you have to remove first k-1 elements and then again insert k elements

so correct way is to use multiset of size k only
first try at your own

reference code if needed

i hope this help
if you have more doubts regarding this feel free to ask
if your doubt is resolved mark it as resolved from your doubt section inside your course