Test case failing

Hi , one of my test case is exceeding the time limit .Please
help me solve the problem

@imsharan0105 your code is right but this question need to be done with o(n) time using unordered_map , priority queue uses nlogn but using unordered map o(n) so thats why giving tle

Ok thank you for the response

Hey i updated my code but still there is some problem with the code . Please help me debug the code

@imsharan0105 share the updated code here using cb ide