当前位置: 首页 > news >正文

网站域名在哪看网站如何清除百度收录

网站域名在哪看,网站如何清除百度收录,邯郸现代建设集团网站,广告网站开发背景题意#xff1a; 起始有两个石头#xff0c;位置是000和nnn,在这中间有n个石头#xff0c;问如何拿走m块石头后#xff0c;使得他们之间的最小间隔的最大值。 题目#xff1a; Every year the cows hold an event featuring a peculiar version of hopscotch that invo…题意 起始有两个石头位置是000和nnn,在这中间有n个石头问如何拿走m块石头后使得他们之间的最小间隔的最大值。 题目 Every year the cows hold an event featuring a peculiar version of hopscotch that involves carefully jumping from rock to rock in a river. The excitement takes place on a long, straight river with a rock at the start and another rock at the end, L units away from the start (1 ≤ L ≤ 1,000,000,000). Along the river between the starting and ending rocks, N (0 ≤ N ≤ 50,000) more rocks appear, each at an integral distance Di from the start (0 Di L). To play the game, each cow in turn starts at the starting rock and tries to reach the finish at the ending rock, jumping only from rock to rock. Of course, less agile cows never make it to the final rock, ending up instead in the river. Farmer John is proud of his cows and watches this event each year. But as time goes by, he tires of watching the timid cows of the other farmers limp across the short distances between rocks placed too closely together. He plans to remove several rocks in order to increase the shortest distance a cow will have to jump to reach the end. He knows he cannot remove the starting and ending rocks, but he calculates that he has enough resources to remove up to M rocks (0 ≤ M ≤ N). FJ wants to know exactly how much he can increase the shortest distance before he starts removing the rocks. Help Farmer John determine the greatest possible shortest distance a cow has to jump after removing the optimal set of M rocks. Input Line 1: Three space-separated integers: L, N, and M Lines 2…N1: Each line contains a single integer indicating how far some rock is away from the starting rock. No two rocks share the same position. Output Line 1: A single integer that is the maximum of the shortest distance a cow has to jump after removing M rocks Sample Input 25 5 2 2 14 11 21 17 Sample Output 4 Hint Before removing any rocks, the shortest jump was a jump of 2 from 0 (the start) to 2. After removing the rocks at 2 and 14, the shortest required jump is a jump of 4 (from 17 to 21 or from 21 to 25). 分析 由于是求最小间隔的最大值起初我理解成求出最大间隔那么直接连续拿遍历一遍就好那肯定是错的那么如何处理每次拿走石头都有可能改变之间间隔的最小值呢 1.首先考虑到只要拿走石头都会使石头之间的间隔变大那么我们只需要枚举最小的间隔看是否满足拿走k个石头后仍旧是最小间隔。 2.那么如何求的最大的最小间隔呢,我们用二分进行枚举最小间隔即可 3.对石头位置进行排序,为之后的遍历寻找去掉一个石头后计算之间的间隔做准备。 4.dfs(x)xdfs(x)xdfs(x)x是所有石头间的最小间隔即任意两个石头之间的间隔都不能小于xxx,我们可以拿走k块石头那就判断当拿走k块石头后仍是最小间隔即可。当存在拿走大于等于k个石头后仍旧是最小间隔时说明此时最小间隔偏大我们最终需要的是正好拿走k个石头使得该枚举的最小间隔是石头间的最小间隔 AC代码 #includestring.h #includestdio.h #includealgorithm #includeiostream using namespace std; const int M5e410; int n,m,k; int f[M]; bool dfs(int x){///假设x是所有石头间的最大最小间隔则此时需要判断拿走k个石头后是否仍是最小间隔。int num0;for(int i1;im-k;i){///一共m-2-k次循环哪怕不满足while循环prem-kint prenum1;while(premf[pre]-f[num]x){///当存在石头间隔小于最小间隔拿走这个石头,使间隔变大pre;}if(prem){///若假设成立,存在拿走k块石头让石头间隔小于最小间隔return false;}numpre;}return true; } int main(){cinnmk;f[0]0;for(int i1;im;i){cinf[i];}f[m1]n;mm2;sort(f,fm);int r0,ln1;//上界要稍大一些否则mid永远取不到值nwhile(l-r1){int mid(rl)1;if(dfs(mid))//说明此时枚举的间隔较小rmid;else lmid;//是否可能使得所有石头之间的距离不小于d}coutrendl;return 0; }
http://www.pierceye.com/news/931764/

相关文章:

  • 上海城乡建设中级职称报名网站合肥网站建设之4个细节要注意事项
  • 洮南网站建设哪家好鞍山信息港招聘信息网
  • 大气手机网站wordpress 添加设置
  • 公司创建网站销售wordpress缩略图支持外链图
  • php网站开发案例教程 dvdwordpress淘宝客自适应模板
  • 做建筑设计网站可以推广的网站有哪些
  • 安徽省建设厅证书查询官方网站关键词优化公司如何选择
  • io游戏网站青岛网站优化排名
  • 怎样建设网站?(怎样注册域名?如何选择主机?网站应有哪些功能模块网站备案可以变更吗
  • 欧美男女直接做的视频网站广告投放跟网站建设一样吗
  • 建网站的流程费用广州比较大的外贸公司
  • wordpress 调用站外api广州优化公司推广
  • 自贡建设专业网站设计企业网站建设专家
  • 重庆潼南网站建设哪家便宜淄博做网站电话
  • 下载官方网站合肥建站公司seo
  • 做网站还是做app好科技部政服务服平台
  • 东阿聊城做网站的公司seo顾问培训
  • 临海高端营销型网站建设地址建设网站有什么要素构成
  • wordpress 照片分享昌平网站建设推广优化seo
  • 石家庄做网站的公司有哪些做企业网站一般要多少钱
  • 电脑十大免费游戏网站万能搜索引擎入口
  • 菏泽网站建设公司排名有没有专做推广小说的网站
  • 东莞网站建设搭建因酷网站建设
  • 连云港百度推广网站建设ph域名网站
  • 网站建设营销模板网站开发招聘职位
  • 如何做网站的教程网站怎么建设以及维护
  • 信息港发布信息怎么做网站优化
  • 网页广告怎么关闭网站seo的主要优化内容
  • server2012做网站免费的图片做视频在线观看网站
  • 石狮网站建设折扣网站模板