编程介的小学生 2017-03-14 01:14 采纳率: 20.5%
浏览 857
已采纳

Jam's Store

Jam has a very large store full of valuable gems. The store is so large that Jam has hired many guards to watch the store. Each guard stays at a fixed position. But recently, Jam found out that there were still some gems stolen. So he decided to rearrange all his guards such that the minimum distance between those guards is maximized. The strategy is to ask each guard to go up or down one unit distance. That is, a guard at position (x,y) may be rearranged to (x,y+1) or (x,y-1).

However, it is not an easy task. So Jam is asking you for help. It is given that initially all the guards are not staying at the same row, that is, for each two guards at (x1, y1) and (x2, y2), y1 is not equal to y2.

Input
The input contains multiple test cases. For each test case the first line contains an integer N (2 <= N <= 200), which is the number of guards Jam has hired. The following N lines each contains two integers, which represent a guard's position (x,y) where 0 <= x, y <= 5000. A case with N = 0 signals the end of the input and must not be processed.

Output

For each case, output in one line the maximized minimum distance between the guards after the rearrangement (accurate up to 3 decimal places).

Sample Input

3
0 0
1 1
2 3
2
4518 1596
2292 2255
0

Sample Output
2.236
2322.067

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-03-26 14:41
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求帮我调试一下freefem代码
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图