Run error in Hostel Visit

ques: https://hack.codingblocks.com/contests/c/547/1629
code: https://ide.codingblocks.com/s/56508

i think your logic is incorrect, create a max heap and top element will be your ans, every time you get new element push it if it is less than the top most element and remove the top element, else ignore.
Check if you have implemented the above the same.
Hit like if you get it.

1 Like