Hello. I was trying to implement priority queue by myself, though I have used priority_queue from C++ STL many times. I was getting TLE for a very simple problem but when I used STL it got accepted. I believe time complexity of my priority queue for insert and pop() operation is O(log N) and overall complexity of solution is O(NlogN). please see the submission here.