Need help for the hostel visit problem input type
Hostel visit problem
For the given input.
9 3
1 10 10
1 9 9
1 -8 -8
2
1 7 7
2
1 6 6
1 5 5
2
The first two numbers represent queries and K.
So you can see there are 9 queries and the k is given as 3 to you.
Then there are two type of queries denoted by 1 and 2.
On query of type 2 you need to output the kth nearest hostel and on query of type 1 you need to add the given coordinates to your list of constructed hostels.
So first you get a type 1 query.
1 10 10
then again
1 9 9
then again
1 -8 -8
So you now have 3 hostels with ditstances 200, 162, 128 respectively.
Now for query type 2 you need to output 3rd nearest hostel (As k is 3).
Which is dist. 200 (so output 200).
Now you get 1 7 7 another hostel with distance 98.
Then you get 2 so now the 3rd nearst hostel is at 162 (so print 162) (this is 3rd nearest from 200,162,128,98)
Then you add two more hostels.
1 6 6 (dist. 72)
1 5 5 (dist. 50)
Then finaly print the 3rd nearest hostel again as there is type 2 query again.
So print 98 (As you have 50,72,98,128,162,200 in the list).