博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdoj 4004 The Frog's Games(二分)
阅读量:7259 次
发布时间:2019-06-29

本文共 2189 字,大约阅读时间需要 7 分钟。

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

Problem Description
The annual Games in frogs' kingdom started again. The most famous game is the Ironfrog Triathlon. One test in the Ironfrog Triathlon is jumping. This project requires the frog athletes to jump over the river. The width of the river is L (1<= L <= 1000000000). There are n (0<= n <= 500000) stones lined up in a straight line from one side to the other side of the river. The frogs can only jump through the river, but they can land on the stones. If they fall into the river, they
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).
 

 

Input
The input contains several cases. The first line of each case contains three positive integer L, n, and m.
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.
 

 

Output
For each case, output a integer standing for the frog's ability at least they should have.
 

 

Sample Input
6 1 2 2 25 3 3 11 2 18
 

 

Sample Output
4 11
 

 

Source
 
#include 
#include
#include
using namespace std;const int INF= 0x3f3f3f3f ;int d[550000]; int L;int calc(int x){ int now=0; int cnt=0; int ps=0; while(now< L) { now+= x; while(now >=d[ps+1]) ps++; now=d[ps]; cnt++; } return cnt;} int main(){ int n, m; while(scanf("%d%d%d", &L, &n, &m) != EOF) { int minx =0 ; for(int i=1; i<= n; i++) scanf("%d", &d[i]); sort(d+1, d+1+n); d[0]= 0; d[n+1]= L; d[n+2]= INF ; for(int i=1; i<= n+1; i++) if(minx
> 1; if(calc(mid) <= m) { res= mid; right= mid-1; } else left= mid+1; } printf("%d\n", res); } return 0;}

 

转载于:https://www.cnblogs.com/soTired/p/5524845.html

你可能感兴趣的文章
方向向量和法向量
查看>>
nodejs + ionic2 + cordova环境搭建
查看>>
BlockingQueue 堵塞队列
查看>>
vim: vimrc配置文件
查看>>
美化git客户端(命令行)
查看>>
设计模式:概念
查看>>
P4357 [CQOI2016]K远点对(KDTree)
查看>>
sql server 2008 r2 安装文件+图解安装过程+注意事项
查看>>
013_REST Service
查看>>
Android应用程序启动过程(一)总结
查看>>
运筹学整理笔记1
查看>>
jQuery全屏滚动插件fullPage.js
查看>>
IO_字节流_拷贝
查看>>
Django中的FBV和CBV
查看>>
SQL内联、外联的简单理解
查看>>
友情链接
查看>>
Joomla源代码解析
查看>>
Docker集群管理(一)—— 基础docker+swarm+shipyard
查看>>
聊下并发和Tomcat线程数(Updated)
查看>>
bzoj1389
查看>>