spoj#MACHCOOL. Machine Cooling
Machine Cooling
Duck is a buzy guy who has N tasks to do in a single day. The i-th task is scheduled at the Di second starting from 00:00:00, for example, 65 is 00:01:05 and 82800 is 23:00:00. He recently bought M machines to help him complete the tasks automatically. Machines are very powerful that they can complete a task in 0 second, or you can say each machine can complete unlimited number of tasks scheduled at the same second.
"Unused machine is wasted machine", so Duck wants to use exactly M machines to complete all tasks. However, he also wants to maximize the cooling time of each machine whenever it completes a task, in order to make it more durable. Given that the maximum cooling time of each machine is 86400, no matters at what second a machine completes a task, but the cooling time must be the same for all machines. What is the maximum cooling time that every machine can have if you distribute all machines optimally?
Input
The first line is the number of test cases T. (1 ≤ T ≤ 50)
For each test case, it starts with the number of tasks N and the number of machines M. (1 ≤ N ≤ 100, 1 ≤ M ≤ N)
The next line has N integers, Di is the second counting from 00:00:00 that the i-th task is scheduled at. (0 ≤ Di ≤ 86399)
Output
Output the maximum cooling time that every machine can have.
Example
Input: 4 14 8 20 450 1 23605 1002 80727 5360 30000 623 40000 623 8888 959 902 6 6 9328 2018 80012 5840 33333 1024 3 2 727 727 727 8 2 2400 201 65003 73099 123 86399 86399 79821
Output: 5359 86400 0 2277
Explanation
In case 1, we can distribute the i-th machines responsible for different tasks as follows: [1, 5360, 23605, 80727], [20, 8888, 30000, 40000], [450], [1002], [623], [623], [959], [902] And now the maximum cooling time of each machine is 5359, 8886, 86400, 86400, 86400, 86400, 86400 and 86400 respectively, hence for all machines the answer is 5359.</p>In case 2, one machine for one task and both can have the cooling time of 86400.
In case 3, one machine for [727, 727] and another for [727], we then have the cooling time of 0 and 86400, hence the final answer is 0.
In case 4, we can have [123, 2400, 65003, 86399] and [201, 73099, 79821, 86399], we choose 2277 from 2277 and 6578.