Hostel visits problem

can u please explain how the output is coming.

Hi,
In this question, we need to output the distance of the kth nearest hostel that the dean can visit. Since it is already given that dean always start from origin, we need to output of the kth nearest hostel from origin. (it is assumed that distance between (x1,y1) and (x2,y2) is (x2-x1)^2 + (y2-y1)^2)).
Let us take an example.
If the distance of existing hostels from origin is 9,25,36,49 and k=3, the output will be 36.
If a new hostel is added, the array will change accordingly. Like if a hostel at distance 16 is added, array will become 9,16,25,36,49 and the kth hostel now will be 25.
Note that we need to output the kth hostel only when query=2 is given as input.
Hope that resolves your Doubt.

Sir only one test case is passing. What am i doing wrong . Ide->https://ide.codingblocks.com/s/181588

Just use long long in place of int while declaring priority queue i.e use priority_queue pq instead of priority_queue pq.
The rest of ur code is fine.