I was solving the question PSHTRG. Basically it is a segment tree problem. I stored 45 greatest elements of each range as the node in segment tree and then for each query I used these elements to find the answer. But my code is giving TLE. I think there is nothing wrong with the logic but I am not able to optimize the code. Please can someone help. Thanks in advance.