TLE in Hussain Set problem

I’m new here, my sincere apologies if i make any mistake.
So, i was doing this problem (COOK82C Problem - CodeChef) but it is showing a TLE.
I used heap in my solution (B9dubF - Online C++ Compiler & Debugging Tool - Ideone.com) 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: