United States of Eurasia
Time limit20sMemory limit1024 MB
Split N points sorted by x into at most K contiguous groups, minimizing the largest squared diameter within any group.
- Level
Hard9 of 10
- Topics
- Binary search, Dynamic programming, Divide and conquer, Geometry
- Solved
- No attempts yet
Problem
In the year 5013 an emperor conquered the continent of Eurasia and founded the United States of Eurasia. The country is wide enough to cover the whole continent and its population is large, so the emperor wants to split the territory into provinces and manage them efficiently. The country has houses, and house stands at in the two dimensional Euclidean plane. The emperor assigns the houses to provinces under the following conditions.
- Condition 1. Each province manages the houses whose coordinate falls inside one interval. A province may manage every house, and a province may manage no house at all.
- Condition 2. Every house must be managed by exactly one province.
- Condition 3. At most provinces can be created.
Eurasia has many races, religions and peoples. To prevent conflicts among them, the division inside each province has to be as small as possible. The division of a province is the distance between the farthest pair of houses that the province manages. The distance is the Euclidean distance. Help the emperor and make the largest division among the provinces as small as possible.
Input
The first line contains the number of houses and the number of provinces , separated by a space.
Each of the next lines contains two integers and separated by a space, which means that a house stands at .
Output
Let be the largest division among the provinces when the houses are split so that this largest division is as small as possible. Print . All coordinates are integers, so is always an integer.
Constraints
- All house coordinates are distinct. That is, if , then or holds.