Organization
Time limit2sMemory limit512 MB
Partition N points into k nonempty teams so that the minimum Manhattan distance between points in different teams is as large as possible.
- Level
Medium7 of 10
- Topics
- Binary search, Sorting, Geometry
- Solved
- No attempts yet
Problem
A company has employees and splits them into nonempty teams. The company turns everything into numbers.
- Employee took two tests and got two values and .
- The difference between employees and is .
- The strength index of the company is the smallest over all pairs of employees , that sit in different teams.
Next year the company keeps teams and rearranges the employees so that the strength index is as large as possible. Compute the largest strength index that nonempty teams can reach.
Input
The first line contains the number of test cases . ()
The first line of each test case contains the number of employees and the number of teams , separated by a single space. (, )
Each of the next lines contains the two test results and of one employee, separated by a single space. ()
Output
For each test case, print the largest strength index on its own line.
Hint
Take the three employees , , with . Neither team may be empty, so there are three ways to split them. with gives , with gives , and with gives . The largest value is .
Take the six employees , , , , , with . There are 31 ways to split them, and with reaches the largest value . That value comes from and from .