HDU5037(SummerTrainingDay01-C)
Frog
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 4467 Accepted Submission(s): 1069
Problem Description
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
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
Sample Input
Sample Output
Source
//2017-10-08
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm> using namespace std; const int N = ;
int arr[N], n, m, l, ans, T; int main(){
int kase = ;
scanf("%d", &T);
while(T--){
scanf("%d%d%d", &n, &m, &l);
arr[] = ;
arr[n+] = m;
for(int i = ; i <= n; i++)
scanf("%d", &arr[i]);
sort(arr, arr+n+);
ans = ;
int k = l;
for(int i = ; i <= n+; i++){
int a = (arr[i]-arr[i-])%(l+);
int b = (arr[i]-arr[i-])/(l+);
if(a+k >= l+){
k = a;
ans += *b+;
}else{
k += a;
ans += *b;
}
}
cout<<"Case #"<<++kase<<": "<<ans<<endl;
} return ;
}
HDU5037(SummerTrainingDay01-C)的更多相关文章
- hdu5037 Frog (贪心)
http://acm.hdu.edu.cn/showproblem.php?pid=5037 网络赛 北京 比较难的题 Frog Time Limit: 3000/1500 MS (Java/Othe ...
- 【数学,方差运用,暴力求解】hdu-5037 Galaxy (2014鞍山现场)
话说这题读起来真费劲啊,估计很多人做不出来就是因为题读不懂...... 从题目中提取的几点关键点: 题目背景就是银河系(Rho Galaxy)中的星球都是绕着他们的质心(center of mass) ...
- HDU5037 Frog
Once upon a time, there is a little frog called Matt. One day, he came to a river. The river could b ...
随机推荐
- 虚拟机下Linux操作Ubuntu
备忘Ubuntu虚拟机环境配置 目录 更新源修改 #支持https的下载 apt 源使用 HTTPS 以确保软件下载过程中不被篡改.因此,我们首先需要添加使用 HTTPS 传输的软件包以及 CA 证书 ...
- 团队作业第五周(HCL盐酸队)
一.Alpha版本测试报告 1.测试计划 测试项目 上下移动 左右移动 发射子弹 与敌方坦克进行攻击 2.测试过程 测试截图 错误记录(提交issues到码云团队项目) 3.测试找出的bu ...
- bash编程-执行流程
1.顺序执行 shell脚本按从上到下的顺序依次执行,除非使用了选择.循环等执行流程. 2.选择执行 2.1 if # 格式一 if 条件; then # 语句 fi # 格式二 if 条件; the ...
- Rocketmq日志收集与logback集成Demo
官方文档有简洁的例子,这里就做一个简单补充和实践 直接上logback-boot.xml文件 <?xml version="1.0" encoding="UTF-8 ...
- 【Spark调优】:结合业务场景,优选高性能算子
聚合操作使用reduceByKey/aggregateByKey替代groupByKey 参见我的这篇博客说明 [Spark调优]:如果实在要shuffle,使用map侧预聚合的算子 内存充足前提下使 ...
- Win10 Hyper-v下虚拟机使用无线网络
首先要承认一点的是写这个随笔更大的初衷是想吐槽,搜了半天,全是一种方法,就是创建一个新的网络适配器,配置为外部网络啥啥啥,用倒是能用,就是网速那叫一个感人,我的是电信百兆光纤网页打开都如蜗牛爬,无法忍 ...
- javascript 实现数据结构 - 队列
队列是遵循FIFO(First In First Out,先进先出,也称为先来先服务)原则的一组有序的项.队列在尾部添加新元素,并从顶部移除元素.最新添加的元素必须排在队列的末尾. 1.构造函数构建队 ...
- css选择符权重
css选择符权重 目录 css选择符权重 css选择器权重列表 CSS选择符冲突处理 css选择符权重 css选择器权重列表 选择器 权重 内联样式 1000 ID 0100 CLASS 0010 属 ...
- Jenkins系列之二——centos 6.9 + JenKins 安装
centos 6.9 + JenKins 安装记录环境: [root@localhost ~]# cat /etc/issue CentOS release 6.9 (Final) Kernel \r ...
- ckeditor 在dwz里面使用
在ckeditor的配置的过程中,所有的配置的地方都配置了,但是就是不显示编辑器(编辑器代码如下),很郁闷哦 1 <textarea id="editor1" name=&q ...