Split N points sorted by x into at most K contiguous groups, minimizing the largest squared diameter within any group.
Hard9Binary searchDynamic programmingDivide and conquerGeometryNo attempts yetTime limit20sMemory limit1024 MBIn 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 N houses, and house i stands at (xi,yi) in the two dimensional Euclidean plane. The emperor assigns the houses to provinces under the following conditions.
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.
The first line contains the number of houses N and the number of provinces K, separated by a space.
Each of the next N lines contains two integers xi and yi separated by a space, which means that a house stands at (xi,yi).
Let M be the largest division among the provinces when the houses are split so that this largest division is as small as possible. Print M2. All coordinates are integers, so M2 is always an integer.