题目链接

题意理解的有些问题。

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define LL __int64
LL p[];
int n;
int judge(int x,int m)
{
int pre = ,num = ,i;
for(i = ;i <= n;i ++)
{
if(p[i] - pre <= x)
;
else
{
num ++;
pre = p[i-];
}
}
if(num + > m)
return ;
else
return ;
}
int main()
{
int m,i,l;
LL str,mid,end,minz;
while(scanf("%d%d%d",&l,&n,&m)!=EOF)
{
for(i = ; i < n; i ++)
scanf("%I64d",&p[i]);
sort(p,p+n);
if(n == ||m == )
{
printf("%d\n",l);
continue;
}
p[n] = l;
minz = p[];
for(i = ;i < n;i ++)
{
minz = max(minz,p[i+]-p[i]);
}
str = minz;end = l;
while(str < end)
{
mid = (str+end)/;
if(judge(mid,m) == )
str = mid + ;
else
end = mid;
}
printf("%I64d\n",str);
}
return ;
}

HDU 4004 The Frog's Games(二分)的更多相关文章

  1. HDU 4004 The Frog's Games(二分答案)

    The Frog's Games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) ...

  2. HDU 4004 The Frog's Games(二分+小思维+用到了lower_bound)

    The Frog's Games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) ...

  3. HDU 4004 The Frog's Games(2011年大连网络赛 D 二分+贪心)

    其实这个题呢,大白书上面有经典解法  题意是青蛙要跳过长为L的河,河上有n块石头,青蛙最多只能跳m次且只能跳到石头或者对面.问你青蛙可以跳的最远距离的最小值是多大 典型的最大值最小化问题,解法就是贪心 ...

  4. hdu 4004 The Frog's Games

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4004 The annual Games in frogs' kingdom started again ...

  5. 杭电 4004 The Frog's Games 青蛙跳水 (二分法,贪心)

    Description The annual Games in frogs' kingdom started again. The most famous game is the Ironfrog T ...

  6. D - The Frog's Games (二分)

    The annual Games in frogs' kingdom started again. The most famous game is the Ironfrog Triathlon. On ...

  7. The Frog's Games(二分)

    The Frog's Games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) ...

  8. HDUOJ----4004The Frog's Games(二分+简单贪心)

    The Frog's Games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) ...

  9. HDU 4004 二分

    The Frog's Games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) ...

随机推荐

  1. 常用的Java代码汇总

    1. 字符串有整型的相互转换           Java   1 2 <strong>Stringa=String.valueOf(2);   //integer to numeric ...

  2. 【译】DotNet 5.4或者说 .NET平台标准

    原文:DotNet 5.4 or .NET Platform Standards 是的,你看到的确实是"DotNet 5.4".使用Visual Studio 2015 RC1 u ...

  3. PAT A 1014. Waiting in Line (30)【队列模拟】

    题目:https://www.patest.cn/contests/pat-a-practise/1014 思路: 直接模拟类的题. 线内的各个窗口各为一个队,线外的为一个,按时间模拟出队.入队. 注 ...

  4. zookeeper源码分析二FASTLEADER选举算法

    如何在zookeeper集群中选举出一个leader,zookeeper使用了三种算法,具体使用哪种算法,在配置文件中是可以配置的,对应的配置项是"electionAlg",其中1 ...

  5. css3设置边框属性

    css设置边框属性:设置边框圆角 <!DOCTYPE html> <html> <head lang="en"> <meta charse ...

  6. C# 键值对类相关

    一 C# 键值对类有以下类: ①    IDictionary<string, Object> idc = new Dictionary<string, object>(); ...

  7. windows加入path路径

    右键我的电脑,属性:高级系统设置,高级,环境变量:在系统变量中选path,编辑:将python安装路径加入即可(注意分号):

  8. DSP using MATLAB 示例Example3.7

    上代码: x1 = rand(1,11); x2 = rand(1,11); n = 0:10; alpha = 2; beta = 3; k = 0:500; w = (pi/500)*k; % [ ...

  9. DSP using MATLAB 示例Example2.12

    代码: b = [1]; a = [1, -0.9]; n = [-5:50]; h = impz(b,a,n); set(gcf,'Color','white'); %subplot(2,1,1); ...

  10. jade学习01

    编写 简单例子 doctype html html head title learn jade body h1 learn jade 常用命令 编译: jade index.jade //默认编译成压 ...