题目链接:http://poj.org/problem?id=3258

River Hopscotch
Time Limit: 2000MS   Memory Limit: 65536K
Total Submissions: 22092   Accepted: 9138

Description

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 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 Mrocks.

Input

Line 1: Three space-separated integers: LN, and M 
Lines 2..N+1: 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).

Source

USACO 2006 December Silver
题目大意:输入L N M  L代表所有的石头距离在起点的最大距离 N代表有N个石头  M代表你可以消去M个石头  问你消去M个石头之后   你走的每一步里面最小值的最大值是多少
思路: 赤裸裸的二分 但是自己没想到 真的菜   其实自己的思路是  先把所有的点里原点的距离从小到大排序一遍,然后取最小的。 但是这样不容易处理啊  因为你取了一个的话  后面一个的距离和前面一个的
距离就变了  如果要维护这一点的话  就算你记录了他们的下标  也改变了后面一个点和前面一个点的距离  然后呢?  你又得把新得到的数组重新从小到大排序  真的不好控制
但是二分来解是真的快!
二分的是答案    思路真的简单  但是没有想到     仔细想想,答案肯定在0-L之间的   判断一个值能否成立也很容易  太菜了。。。
看代码:

转载于:https://www.cnblogs.com/caijiaming/p/10356054.html

River Hopscotch相关推荐

  1. bzoj 1650: [Usaco2006 Dec]River Hopscotch 跳石子(二分)

    1650: [Usaco2006 Dec]River Hopscotch 跳石子 Time Limit: 5 Sec  Memory Limit: 64 MB Submit: 721  Solved: ...

  2. 【POJ No. 3258】 跳房子游戏 River Hopscotch

    [POJ No. 3258] 跳房子游戏 River Hopscotch POJ题目地址 [题意] 跳房子游戏指从河中的一块石头跳到另一块石头,这发生在一条又长又直的河流中,从一块石头开始,到另一块石 ...

  3. River Hopscotch问题(二分)

    又是一个卡了我好久好久好久的二分题 我真的不会二分啊,有没有大佬可以给我讲讲 我就是个憨憨 题目链接River Hopscotch 题目描述: Every year the cows hold an ...

  4. POJ 3258 River Hopscotch 经典二分

    点击打开链接 River Hopscotch Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 6189   Accepted: ...

  5. POJ 3258 -- River Hopscotch(二分)

    题目链接 Description Every year the cows hold an event featuring a peculiar version of hopscotch that in ...

  6. 二分+最大化最小值 River Hopscotch POJ - 3258

    题意: 起始有两个石头,位置是000和nnn,在这中间有n个石头,问如何拿走m块石头后,使得他们之间的最小间隔的最大值. 题目: Every year the cows hold an event f ...

  7. POJ 3258:River Hopscotch (最大化最小值)

    [题意] 牛要到河对岸,在与河岸垂直的一条线上,河中有N块石头,给定河岸宽度L,以及每一块石头离牛所在河岸的距离, 现在去掉M块石头,要求去掉M块石头后,剩下的石头之间以及石头与河岸的最小距离的最大值 ...

  8. poj 3258:River Hopscotch(二分)

    题目链接 L为N+2块石子中最右边石子位置,0最左,M为可移除块数,求移除后相邻石子可达到的最大距离. #include<iostream> #include<cstdio> ...

  9. poj3258 River Hopscotch (二分搜索,考虑最大值最小问题)

    每年奶牛们都要举办各种特殊版本的跳房子比赛,包括在河里从一块岩石跳到另一块岩石.这项激动人心的活动在一条长长的笔直河道中进行,在起点和距离起点 L 远的终点各有一块岩石 (1 ≤ L ≤ 10^9). ...

最新文章

  1. 【数字信号处理】相关函数 ( 相关系数与相关函数 | 相关函数定义 )
  2. 【已解决】Jsp实现文件上传功能
  3. python已知Camera及Lidar2到Lidar1外参,求Camera到Lidar2外参
  4. 洛谷P2995奇数偶数
  5. 海润光伏上年净利扭亏“摘帽”在望
  6. Python 安装 lxml 插件
  7. Codeup_575A_剩下的树
  8. 一个“技术文化人”的片段感悟
  9. iTop-4412精英版的u-boot-2017.11移植教程(二)
  10. 超全Python图像处理讲解(多图预警)
  11. 成考计算机专业难不难,成人高考计算机专业难吗?
  12. ProxySQL+MGR实现读写分离和主节点故障无感知切换 - 完整操作记录
  13. 【正点原子Linux连载】第六十七章 Linux USB驱动实验 -摘自【正点原子】I.MX6U嵌入式Linux驱动开发指南V1.0
  14. MATLAB 如何生成彩色的eps文件
  15. 宝塔win安装提示非服务器系统,宝塔windows面板安装
  16. 对校招生培养工作的建议_学校招生工作的几点建议
  17. 每日java5-27
  18. fundamentals\java\java8新特性-Lambda(译自oracle官网)
  19. 02. 数据库的选择
  20. 独家揭开几项神秘SEO技术的猪八戒面纱

热门文章

  1. (原创)如何解决matlab乱码问题
  2. 基于Pytorch的多任务推荐系统开源框架
  3. 【报告分享】5G零售行业应用白皮书.pdf(附下载链接)
  4. 【论文】最新图学习推荐系统综述 | Graph Learning Approaches to Recommender
  5. 推荐系统系列教程之十二:Facebook是怎么为十亿人互相推荐好友的?
  6. 编译成功,但引用之后报错undefined symbol: _ZN10tensorflow7strings6StrCatERKNS0_8AlphaNumE
  7. 全球首发!计算机视觉Polygon Mesh Processing总结8——Remeshing Global Structure和Correspondences
  8. 基于检索的自然语言处理模型研究梳理
  9. 细数python标准库中低调的模块
  10. 梯度下降优化算法总结