The Frog's Games(二分)
The Frog's Games
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)
Total Submission(s): 5676 Accepted Submission(s): 2732
are out. The frogs was asked to jump at most m (1<= m <= n+1) times. Now the frogs want to know if they want to jump across the river, at least what ability should they have. (That is the frog's longest jump distance).
Then n lines follow. Each stands for the distance from the starting banks to the nth stone, two stone appear in one place is impossible.
2
25 3 3
11
2
18
11
#include<stdio.h>
#include<queue>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<set>
#include<vector>
using namespace std;
const int MAXN = ;
int L, n, m;
int ston[MAXN];
bool js(int x){
int cnt = , last = ston[];
for(int i = ; i <= n; i++){
if(ston[i] - ston[i - ] > x)
return false;
if(ston[i] - last > x){
cnt++;
last = ston[i - ];
if(cnt >= m)
return false;
}
}
return true;
}
int erfen(int l, int r){
int mid, ans;
while(l <= r){
mid = (l + r) >> ;
if(js(mid)){
ans = mid;
r = mid - ;
}
else
l = mid + ;
}
return ans;
}
int main(){
while(~scanf("%d%d%d", &L, &n, &m)){
for(int i = ; i <= n; i++)
scanf("%d", ston + i);
ston[] = ;
ston[n + ] = L;
n++;
sort(ston, ston + n + );
printf("%d\n", erfen(, L));
}
return ;
}
The Frog's Games(二分)的更多相关文章
- HDU 4004 The Frog's Games(二分答案)
The Frog's Games Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others) ...
- 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) ...
- D - The Frog's Games (二分)
The annual Games in frogs' kingdom started again. The most famous game is the Ironfrog Triathlon. On ...
- HDU 4004 The Frog's Games(二分)
题目链接 题意理解的有些问题. #include <iostream> #include<cstdio> #include<cstring> #include< ...
- HDUOJ----4004The Frog's Games(二分+简单贪心)
The Frog's Games Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others) ...
- The Frog's Games
The Frog's Games Problem Description The annual Games in frogs' kingdom started again. The most famo ...
- HDU 4004 The Frog's Games(2011年大连网络赛 D 二分+贪心)
其实这个题呢,大白书上面有经典解法 题意是青蛙要跳过长为L的河,河上有n块石头,青蛙最多只能跳m次且只能跳到石头或者对面.问你青蛙可以跳的最远距离的最小值是多大 典型的最大值最小化问题,解法就是贪心 ...
- hdu 4004 The Frog's Games
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4004 The annual Games in frogs' kingdom started again ...
- H - The Frog's Games
The annual Games in frogs' kingdom started again. The most famous game is the Ironfrog Triathlon. On ...
随机推荐
- 使用markdown语法撰写csdn博客
在CSDN之下写blog无疑是一件非常吃力的事情,对于非常多simple爱好者来讲,能用markdown语法来书写代码是最优雅简洁只是的了.本文主要介绍markdown语法和怎样它来撰写csdn下的b ...
- OpenMp 基本
OpenMp是由OpenMP Architecture Review Board牵头提出的,并已被广泛接受的,用于共享内存并行系统的多线程程序设计的一套指导性的编译处理方案(Compiler Di ...
- linux下单独安装oracle12.1客户端
1.安装oracle-instantclient:(默认安装即可) oracle-instantclient12.1-sqlplus-12.1.0.1.0-1.x86_64.rpmoracle-ins ...
- Android SQLite API的使用(非原创)
1.使用SQLite的API来进行数据库的添加.删除.修改.查询 package com.example.sqlitedatabase.test; import android.content.Con ...
- myeclipse修改内存
安装完成后,在安装目录有个config.ini文件,内容如下:-vmargs-Xms40m-Xmx256m Xms:初始化内存大小xmx:最大内存大小用编辑工具打开他,把Xms 和Xmx更改成自己需要 ...
- MFC下的aero效果学习笔记
最近想在MFC中用下aero 首先参考了 http://blog.csdn.net/polytechnic/article/details/5696797 中的一系列的步骤,进行了初步学习 但是对于其 ...
- mysql 8小时空闲后连接失效的解决
查了一下发现应用程序和mysql数据库建立连接,如果超过8小时应用程序不去访问数据库,数据库就断掉连接 .这时再次访问就会抛出异常. 关于mysql自动断开的问题研究结果如下, 1.c3p0.Hika ...
- Linux 下源码安装JDK
一,找到.tar.gz源码包 将jdk1.XXXXXXX.tar.gz源码包放在你想方的位置,比如我就放到u盘的 1, mkdir /mnt/udisk ...
- 关于Repeater中绑定的控件不触发ItemCommand事件
今天遇到 在repeater 中使用一个button,点击button然后跳转另外一个页面. html. <asp:Repeater ID="repeater" runat= ...
- 利用java反射机制对方法进行调用
http://blog.csdn.net/coolcoffee168/article/details/5835143