I think your mp.find() method is eating up lot of time.
I used priority queue & binary search to get my solution accepted. In my solution, I maintain an extra array to check whether a number is already in the queue or not. Maybe you should do something similar.
Completely true…We implemented during the competition using Linked Lists and did a binary search but still it gave TLE…I guess using priority queues was the only way to get accepted