TLE in Hussain Set problem

I’m new here, my sincere apologies if i make any mistake.
So, i was doing this problem ( but it is showing a TLE.
I used heap in my solution ( and well commented it.
I think it should run as it have a time complexity of O(k*logn).
Can anyone help me in this?
Thanks in advance :slight_smile: