K Devices

3.4

46 votes
Basic Programming, Easy
Problem

You are given the location of N devices on a coordinate plane and an integer K. Location of ith device is donated by (Xi,Yi). A modem is located at (0,0). The range of modem is circular. All the devices within the range of the modem will connect to the modem. You have to find the minimum integral radius of the circular range of the modem such that at-least K devices will connect to the modem.

Input:
First line contains two integers, N (1N105) and K (1KN). Second line contains N space separated integers denoting the array X (109Xi109). Third line contains N space separated integers denoting the array Y (109Yi109).

Output:
Print one integer, denoting the minimum integral radius of the circular range of the modem such that at-least K devices will connect to the modem.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

All the devices are at distance 2 from the modem. So, the minimum integral radius of the circular range of the modem such that at-least 3 devices will connect to the modem will be 2.

Editor Image

?