What's wrong in the code

I have tried to do this question…
Here is my code…


But it is showing wrong answer for many test cases and tle for one…
Whats wrong in my code.

Hey @ashishnnnnn
Use long long instead of int
Also to avoid TLE, mantain heap of size k only
So that insertion time can be optimized