Could you tell me the optimal way (hint) using stl to this type of question.
Need a hint to proceed
See you need to give kth nearest distance and you have queries upto 1e5 . So what you need every time is kth nearest so for this you can use a priority_queue which contain kth largest distance from origin to its top. So every time you have to query you only need to print the top of priority queue , and while you are inserting if size of priority queue is greater than k , all you have to do is remove the topmost element.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.