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 ...
随机推荐
- Understanding Abstractions of Secure Channels 的研读
- 监控工具zabbix
1 安装zabbixyum install -y epel-release安装rpm包的lamp环境 yum install httpd mysql mysql-libs php php-mysql ...
- Linux 统计代码行数命令
wc -l `find . -name '*.js'` wc -l `find . -regex ".*\.js"`
- (转)ie -ms-interpolation-mode: bicubic 属性详解
ie -ms-interpolation-mode: bicubic 属性详解 img { -ms-interpolation-mode: bicubic; } 这个在做实时缩放图片.缩略图的时候用 ...
- (三)CodeMirror - Event
"change" (instance: CodeMirror, changeObj: object) { from, // object to, // object text, / ...
- 18 java 代理模式 (转)
静态代理 1.新建一个接口,这个接口所提供的方法是关于数据库操作的 public interface EmployeeDao { public void updateSalary(); } 2.建一个 ...
- hdu 确定比赛名次
算法:拓扑排序 题意:有一个比赛,现在知道很多队之间的关系:让你去让确定比赛排名: Problem Description 有N个比赛队(1<=N<=500),编号依次为1,2,3,... ...
- Reverse digits of an integer.
class Solution { public: int reverse(int x) { ;//long 是怕中间过程溢出 <<,max=-min-){ ans=ans*+x%; x=x ...
- MFC中函数名前加 :: 原因
在开发MFC之前,开发的是以AFx(Application Frameworks,x是没有什么意义的)开头的一些函数.但是那个时候开发的函数并没有进行封装,但是有很多很有用的函数.最后AFx开发失败, ...
- cocos2dx 字体描边方法介绍
转载地址:http://www.taikr.com/group/2/thread/1606 关于cocos2dx 字体描边的实现,不考虑效果和效率的话,是有三种方式: ① 利用CCLabelTTF制作 ...