2014北京网络预选赛1006(贪心)HDU5037
来源:互联网 发布:linuxapp源码下线 编辑:程序博客网 时间:2024/04/25 14:04
Frog
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1357 Accepted Submission(s): 364
Problem Description
Once upon a time, there is a little frog called Matt. One day, he came to a river.
The river could be considered as an axis.Matt is standing on the left bank now (at position 0). He wants to cross the river, reach the right bank (at position M). But Matt could only jump for at most L units, for example from 0 to L.
As the God of Nature, you must save this poor frog.There are N rocks lying in the river initially. The size of the rock is negligible. So it can be indicated by a point in the axis. Matt can jump to or from a rock as well as the bank.
You don't want to make the things that easy. So you will put some new rocks into the river such that Matt could jump over the river in maximal steps.And you don't care the number of rocks you add since you are the God.
Note that Matt is so clever that he always choose the optimal way after you put down all the rocks.
The river could be considered as an axis.Matt is standing on the left bank now (at position 0). He wants to cross the river, reach the right bank (at position M). But Matt could only jump for at most L units, for example from 0 to L.
As the God of Nature, you must save this poor frog.There are N rocks lying in the river initially. The size of the rock is negligible. So it can be indicated by a point in the axis. Matt can jump to or from a rock as well as the bank.
You don't want to make the things that easy. So you will put some new rocks into the river such that Matt could jump over the river in maximal steps.And you don't care the number of rocks you add since you are the God.
Note that Matt is so clever that he always choose the optimal way after you put down all the rocks.
Input
The first line contains only one integer T, which indicates the number of test cases.
For each test case, the first line contains N, M, L (0<=N<=2*10^5,1<=M<=10^9, 1<=L<=10^9).
And in the following N lines, each line contains one integer within (0, M) indicating the position of rock.
For each test case, the first line contains N, M, L (0<=N<=2*10^5,1<=M<=10^9, 1<=L<=10^9).
And in the following N lines, each line contains one integer within (0, M) indicating the position of rock.
Output
For each test case, just output one line “Case #x: y", where x is the case number (starting from 1) and y is the maximal number of steps Matt should jump.
Sample Input
21 10 552 10 336
Sample Output
Case #1: 2Case #2: 4
题意:RT
思路:比较好的贪心题了
每次只需要记录上一步跳的距离K
然后如果现在可以调的距离为X,分两种情况
如果X+K>=L+1,则可以往前跳X
如果X+K<L+1,则要与上一步合并
具体细节看代码吧,在纸上画一画就懂了
0 0
- 2014北京网络预选赛1006(贪心)HDU5037
- 2014北京网络赛1006||hdu5037 思维题
- 2014鞍山网络预选赛1004(贪心)hdu5000
- HDU5037-贪心(很好)-Frog
- hdu5037(贪心)
- HDU5037 贪心
- 2014北京网络预选赛1005(强连通缩点+期望)HDU5036
- 2014北京网络预选赛1008(线段树区间操作)HDU5039
- 2014鞍山网络预选赛1006(LCT模板题)hdu5002
- hdu5037 Frog 贪心
- HDU5037 frog贪心
- hdu5037 Frog --- 贪心
- hdu5037 Frog --- 贪心
- HDU -- 5037 Frog (贪心)(2014北京网络赛)
- icpc 北京网络赛 1006 贪心算法
- 2014牡丹江网络预选赛E题(线段树)zoj3813
- 2014牡丹江网络预选赛D题(状压DP)zoj3812
- 2014牡丹江网络预选赛B题(找规律)zoj3810
- CRC校验实现原理以及程序实现研究
- 5.反射例子
- JSP学习 —— 开篇:JSP,servlet容器,Tomcat,servlet容器之间的关系
- 为什么在google源码中往往能看到使用 二进制数据
- 6. java基础学习总结1
- 2014北京网络预选赛1006(贪心)HDU5037
- Jsp学习——servlet详解
- Directx 9.0/9.0c 在vs2008 里面的环境配置
- 抛弃C程序设计中的谬误与恶习(3)
- 关于经典开源框架STRUTS2的使用
- 15、NDK_ROOT not defined. Please define NDK_ROOT in your environment解决方案
- 7. java基础学习总结2
- C# DataGridView添加右键菜单等技巧
- ubuntu常见错误及解决