博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
City Upgrades
阅读量:4606 次
发布时间:2019-06-09

本文共 805 字,大约阅读时间需要 2 分钟。

City Upgrades

Time limit: 
1000 ms
Memory limit: 
128 MB

There are N cities placed in a line. For each city ii you know its coodinate x​​. You can upgrade exactly K of these cities. Your goal is to choose what cities to upgrade in a way the minimizes the maximum distance between a regular city and the closest upgraded one.

Standard input

The first line contains two integers N and K.

The second line contains N integers representing the coordinates of the cities.

Standard output

Print a single integer representing the smallest maximum distance between a regular city and the closest upgraded one.

Constraints and notes

  • 1<= K < N<=10^5​​ 
  • 0xi​​10^9

Simple Input:

5 21 2 4 5 10

Simple Ouput:

3

题意:在数轴上有n个点,给定一个k,让你选出k个点,使得剩下n-k个点与这k个点之间的最短距离最小。

解法:二分枚举,然后检查即可

 

转载于:https://www.cnblogs.com/sakumia/p/6523339.html

你可能感兴趣的文章
Java EE的map
查看>>
webdriver.py--解说
查看>>
windows 下配置Eclipse che
查看>>
SearchSploit
查看>>
关于C语言中的转义字符
查看>>
用正则表达式从网页里面提取视频地址
查看>>
JAVA线程优先级
查看>>
解决VC几个编译问题的方法——好用
查看>>
SPOJ #11 Factorial
查看>>
City Upgrades
查看>>
“人少也能办大事”---K2 BPM老客户交流会
查看>>
关于七牛进行图片添加文字水印操作小计
查看>>
DataSource数据库的使用
查看>>
CentOS开启samba实现文件共享
查看>>
MSSQL使用sqlbulkcopy批量插入数据
查看>>
证明一个数能被3整除,当且仅当它的各位数的和能被3整除
查看>>
2018秋寒假作业4—PTA编程总结1
查看>>
android自适应屏幕
查看>>
2019-北航面向对象-电梯作业总结
查看>>
SqlHelper
查看>>