题目链接

题意理解的有些问题。

 #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. sql server 用户'sa'登录失败(错误18456)(转载)

    转载地址:http://thenear.blog.51cto.com/4686262/865544 用户'sa'登录失败(错误18456)解决方案图解 当我们在使用sql server 的时候可能会遇 ...

  2. Delphi版本顺序

    1.02.03.04.05.06.07.08.0200520062007 现在应该又出新的版本了

  3. Python 的三目运算

    其他语言:php 判定条件?为真时的结果:为假时的结果 $a=88 $b=99 $res = $a>$b?$a>$b 搞笑的Python:令人意想不到的语法形式 true_value if ...

  4. Filp Game

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 25573   Accepted: 11052 题目链接: ...

  5. HTML5的input color系统颜色选择器

    前两天,我写了一篇<推荐两款jQuery色盘选择器>介绍,那是使用JavaScript实现的色盘,今天我给大家介绍HTML5的色盘选择器.HTML5有一个input类型为color,即颜色 ...

  6. PostgreSQL简单介绍

    自从MySQL被Oracle收购以后,PostgreSQL逐渐成为开源关系型数据库的首选. 本文介绍PostgreSQL的安装和基本用法,供初次使用者上手.以下内容基于Debian操作系统,其他操作系 ...

  7. 使用AStyle进行代码格式化

    转自:http://www.cnblogs.com/JerryTian/archive/2012/09/20/AStyle.html 在日常的编码当中,大家经常要遵照一些设计规范,如命名规则.代码格式 ...

  8. unfortunately launcher has stopped

    设定虚拟机的配置.

  9. 在ubuntu中安装jdk

    安装环境 操作系统:ubuntu 14.04.1 server amd64 下载jdk wget http://download.oracle.com/otn-pub/java/jdk/7u67-b0 ...

  10. Linux学习笔记(13)权限管理

    1 ACL权限 (1)简介和开启方式 ACL(Access Control List)权限的目的是在提供传统的owner.group.others的read.write.execute权限之外的局部权 ...