题目传送门

 /*
二分:搜索距离,判断时距离小于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. MySQL数据库:SQL语句基础、库操作、表操作、数据类型、约束条件、表之间的关系

    数据库相关概念: 1. 数据库服务器:运行数据库管理软件的计算机 2. 数据库管理软件:MySQL.Oracle.db2.slqserver 3. 库:文件夹,用来组织文件/表 4. 表:文件(类似于 ...

  2. 【http_load】http_load性能测试工具使用详解

    1.什么是http_loadhttp_load是一款基于Linux平台的web服务器性能测试工具,用于测试web服务器的吞吐量与负载,web页面的性能. 2.http_load的安装1)下载地址wge ...

  3. The Java library for converting Wikipedia wikitext notation to HTML

    https://code.google.com/p/gwtwiki/ The Java Wikipedia API (Bliki engine) is a parser library for con ...

  4. Free Goodies UVA - 12260

    Petra and Jan have just received a box full of free goodies, and want to divide the goodies between ...

  5. Same Tree (二叉树DFS)

    Given two binary trees, write a function to check if they are equal or not. Two binary trees are con ...

  6. JSP操作

    以下内容引用自http://wiki.jikexueyuan.com/project/jsp/actions.html: JSP操作(Action)使用XML语法结构来控制Servlet引擎的行为.可 ...

  7. JAVA调用动态链接库(dll)

        菜鸡爬坑 基础知识  因为某个东西的keygen我只会在win下生成!! 所以只能出此下策!!之前一直是android下用jni调用so文件,现在试下java在win平台下调用dll 首先还是 ...

  8. MongoDB小结25 - 复合唯一索引

    只要满足索引的其中之一不同即可 db.blog.ensureIndex({"username":1,"blogname":1}) 作者和作品名其中之一不同即可创 ...

  9. 我的arcgis培训照片12

    来自:http://www.cioiot.com/successview-381-1.html

  10. scp、paramiko、rsync复制文件的区别

    1.paramiko只能复制文件,而不能复制目录,复制时,已经存在的会被覆盖;要想复制目录,只能把目录里的文件一个一个复制过去 2.scp可以复制文件.目录,复制时,已经存在的会被覆盖:可以模糊匹配: ...