Hostel visit problem

my code is not working show TLE and Wrong answer
problem : https://online.codingblocks.com/app/player/39658/content/55466/5368/code-challenge?code=5m1BJhPRmjPV7B8VrFhKUnEy7YXF107q

code : https://ide.codingblocks.com/s/199530

plz reply asap

@sengarankit98
hello ankit,
a) u r getting wrong becuase u r not pushing back those k-1 popped element after getting kth smallest.

b) your approach is inefficient thats why u are getting Tle ,u should use max heap in place of min heap

efficient approach using min heap
image