题目传送门

 /*
二分:搜索距离,判断时距离小于d的石头拿掉
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std; typedef long long ll;
const int MAXN = 5e4 + ;
const int INF = 0x3f3f3f3f;
ll a[MAXN];
int n, m; bool check(ll d) {
int last = ; int cnt = ;
for (int i=; i<=n+; ++i) {
if (a[i] - a[last] <= d) cnt++;
else last = i;
}
return cnt > m;
} int main(void) { //POJ 3258 River Hopscotch
//freopen ("POJ_3258.in", "r", stdin); ll x;
while (scanf ("%I64d%d%d", &x, &n, &m) == ) {
a[] = ; a[n+] = x;
for (int i=; i<=n; ++i) {
scanf ("%I64d", &a[i]);
} sort (a, a+n+); ll l = , r = a[n+];
while (l <= r) {
ll mid = (l + r) >> ;
if (check (mid)) r = mid - ;
else l = mid + ;
}
printf ("%I64d\n", l);
} return ;
}

二分搜索 POJ 3258 River Hopscotch的更多相关文章

  1. POJ 3258 River Hopscotch

    River Hopscotch Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 11031   Accepted: 4737 ...

  2. POJ 3258 River Hopscotch (binarysearch)

    River Hopscotch Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 5193 Accepted: 2260 Descr ...

  3. POJ 3258 River Hopscotch(二分答案)

    River Hopscotch Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 21939 Accepted: 9081 Desc ...

  4. [ACM] POJ 3258 River Hopscotch (二分,最大化最小值)

    River Hopscotch Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 6697   Accepted: 2893 D ...

  5. poj 3258 River Hopscotch 题解

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

  6. poj 3258 River Hopscotch(二分搜索之最大化最小值)

    Description Every year the cows hold an ≤ L ≤ ,,,). Along the river between the starting and ending ...

  7. poj 3258"River Hopscotch"(二分搜索+最大化最小值问题)

    传送门 https://www.cnblogs.com/violet-acmer/p/9793209.html 题意: 有 N 块岩石,从中去掉任意 M 块后,求相邻两块岩石最小距离最大是多少? 题解 ...

  8. POJ 3258 River Hopscotch(二分法搜索)

    Description Every year the cows hold an event featuring a peculiar version of hopscotch that involve ...

  9. poj 3258 River Hopscotch(二分+贪心)

    题目:http://poj.org/problem?id=3258 题意: 一条河长度为 L,河的起点(Start)和终点(End)分别有2块石头,S到E的距离就是L. 河中有n块石头,每块石头到S都 ...

随机推荐

  1. [K3Cloud] QueryService使用注意事项

    QueryServlice是目前查询数据非常好用的服务,但目前在使用过程中由于使用不当产生不少问题,下面将一一解答: 1.在查询一些实体关键字段如实体主键.分录序号时,条件中的别名怎么会变来变去?   ...

  2. [NOIP2005] 提高组 洛谷P1054 等价表达式

    题目描述 明明进了中学之后,学到了代数表达式.有一天,他碰到一个很麻烦的选择题.这个题目的题干中首先给出了一个代数表达式,然后列出了若干选项,每个选项也是一个代数表达式,题目的要求是判断选项中哪些代数 ...

  3. Qmake 工具编译调试

    Qmake 工具编译调试 2015年4月9日星期四 18:38:06 1. 确定qmaek 路径 [root@roger ~]# which qmake /usr/lib/qt-3.3/bin/qma ...

  4. CentOS7使用mount命令来挂载CDROM

    https://blog.csdn.net/testcs_dn/article/details/41448557

  5. HDU.P1100 Trees Made to Order 解题报告

    http://www.cnblogs.com/keam37/p/3637717.html  keam所有 转载请注明出处 Problem Description We can number binar ...

  6. P2212 [USACO14MAR]浇地Watering the Fields 洛谷

    https://www.luogu.org/problem/show?pid=2212 题目描述 Due to a lack of rain, Farmer John wants to build a ...

  7. git: 保存帐号信息

    One line command: git config credential.helper store

  8. [欧拉回路] poj 1300 Door Man

    题目链接: http://poj.org/problem?id=1300 Door Man Time Limit: 1000MS   Memory Limit: 10000K Total Submis ...

  9. android动态控制组件的位置、大小和新的动画

    一.动态设置组件的位置 当中view是须要改变位置的控件,top是须要设制的位置: private static void setLayoutX(View view,int top)  { //克隆v ...

  10. cocos2dx游戏开发学习笔记2-从helloworld開始

    一.新建project 具体安装和新建project的方法在cocos2dx文件夹下的README.md文件里已经有具体说明,这里仅仅做简介. 1.上官网下载cocos2dx-3.0的源代码.http ...