HDU 5112 A Curious Matt (2014ACM/ICPC亚洲区北京站-重现赛)
A Curious Matt
Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others)
Total Submission(s): 3058 Accepted Submission(s):
1716
One day,
Matt's best friend Ted is wandering on the non-negative half of the number line.
Matt finds it interesting to know the maximal speed Ted may reach. In order to
do so, Matt takes records of Ted’s position. Now Matt has a great deal of
records. Please help him to find out the maximal speed Ted may reach, assuming
Ted moves with a constant speed between two consecutive records.
indicates the number of test cases.
For each test case, the first line
contains an integer N (2 ≤ N ≤ 10000),indicating the number of
records.
Each of the following N lines contains two integers
ti and xi (0 ≤ ti, xi ≤
106), indicating the time when this record is taken and Ted’s
corresponding position. Note that records may be unsorted by time. It’s
guaranteed that all ti would be distinct.
where x is the case number (starting from 1), and y is the maximal speed Ted may
reach. The result should be rounded to two decimal places.
3
2 2
1 1
3 4
3
0 3
1 5
2 0
Case #2: 5.00
In the first sample, Ted moves from 2 to 4 in 1 time unit. The speed 2/1 is maximal.
In the second sample, Ted moves from 5 to 0 in 1 time unit. The speed 5/1 is maximal.
#include<bits/stdc++.h>
using namespace std;
const int M = +;
struct node{
double t;
double d;
}a[M];
bool cmp(const node &x,const node &y){
return x.t < y.t;
}
int main()
{
int t,i,n,j;
while(scanf("%d",&t)!=EOF){
for(j=;j<=t;j++){
scanf("%d",&n);
for(i=;i<=n;i++){
scanf("%lf%lf",&a[i].t,&a[i].d);
}
sort(a+,a+n+,cmp);
double ans;
double maxx = ;
for(i=;i<n;i++){
ans = fabs(a[i+].d - a[i].d)*1.0/fabs(a[i+].t - a[i].t)*1.0;
maxx = max(maxx,ans);
}
cout<<"Case #"<<j<<": ";
printf("%.2lf\n",maxx);
}
}
}
HDU 5112 A Curious Matt (2014ACM/ICPC亚洲区北京站-重现赛)的更多相关文章
- HDU 5127.Dogs' Candies-STL(vector)神奇的题,set过不了 (2014ACM/ICPC亚洲区广州站-重现赛(感谢华工和北大))
周六周末组队训练赛. Dogs' Candies Time Limit: 30000/30000 MS (Java/Others) Memory Limit: 512000/512000 K ( ...
- HDU 5135.Little Zu Chongzhi's Triangles-字符串 (2014ACM/ICPC亚洲区广州站-重现赛)
Little Zu Chongzhi's Triangles Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 512000/512000 ...
- HDU 5131.Song Jiang's rank list (2014ACM/ICPC亚洲区广州站-重现赛)
Song Jiang's rank list Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 512000/512000 K (Java ...
- Hdu OJ 5115 Dire Wolf (2014ACM/ICPC亚洲区北京站) (动态规划-区间dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5115 题目大意:前面有n头狼并列排成一排, 每一头狼都有两个属性--基础攻击力和buff加成, 每一头 ...
- hdu 5112 A Curious Matt
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5112 A Curious Matt Description There is a curious ma ...
- HDU 5112 A Curious Matt 水题
A Curious Matt Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid ...
- 2014ACM/ICPC亚洲区北京站
1001 A Curious Matt 求一段时间内的速度单位时间变化量,其实就是直接求出单位时间内的,如果某段时间能达到最大那么这段时间内必定有一个或一小段单位时间内速度变化是最大的即局部能达到最 ...
- HDU-5532//2015ACM/ICPC亚洲区长春站-重现赛-F - Almost Sorted Array/,哈哈,水一把区域赛的题~~
F - Almost Sorted Array Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & ...
- 水题:HDU 5112 A Curious Matt
Description There is a curious man called Matt. One day, Matt's best friend Ted is wandering on the ...
随机推荐
- 第9章 初识STM32固件库
第9章 初识STM32固件库 全套200集视频教程和1000页PDF教程请到秉火论坛下载:www.firebbs.cn 野火视频教程优酷观看网址:http://i.youku.com/fire ...
- jpbm工作流框架
一:JBPM是什么?有什么用?能解决什么问题? 现实生活中有很多需要走一些流程的过程,比如请假流程,报销流程等,使用工作流框架,即可写一个流程即可,添加流程时不在繁琐的建立新的各种配置. 1:jBPM ...
- 20155317王新玮《网络对抗技术》实验9 web安全基础实践
20155317王新玮<网络对抗技术>实验9 web安全基础实践 一.实验准备 1.0 实验目标和内容 Web前端HTML.能正常安装.启停Apache.理解HTML,理解表单,理解GET ...
- Android开发——为EditText添加烟花效果的实现
)什么时候发射烟花:监听EditText的文字改变,获取文字数量的变化以确定风的方向,还有获取光标的位置确定爆炸的位置.光标的位置没有具体的方法确定坐标,要通过反射自己计算. 2. 主要实现类 库里 ...
- VS相关
快速显示函数名称 ctrl+alt+T 显示函数参数说明 ctrl+shift+space,光标放在函数里面 link 1123错误,vs2010的问题. 点击工程-属性-ManifestTool-I ...
- [APIO2013]机器人[搜索、斯坦纳树]
题意 题目链接 分析 记 g(d,x,y) 表示从 (x,y) 出发,方向为 d 到达的点,这个可以通过记忆化搜索求出,注意如果转移成环(此时向这个方向走没有意义)要特判. 记 f(l,r,x,y) ...
- Macaca之Android原理浅析
经过研究macaca的android模块源码,原理主要由以下三块构成 一.uiautomator TODO 二.nanohttp TODO 二.adb forward TODO
- 记录下安装ES过程中遇到的错误及解决
1.集群配置 需要修改 cluster.name .node.name .network.host: 0.0.0.0[此处默认localhost].http.port: 9200 只要集群名相同,且机 ...
- 搭建CodeReivew 工具 Phabricator
简介 现在项目成本投入高了,自然对项目的质量要求也愈来愈高,像发布好还发现明显的 bug,或性能低下这种问题已不能接受. 由于产品的质量和代码质量密切相关,而开发团队里并不是每个人都是大神,大家的经验 ...
- MOSFET简介以及PMOS和NMOS的差异
最近在工作中,一直在调试关于MOSFET的电路.在设计过程中发现了PMOS和NMOS的差异,在此记录. 一. MOSFET简介 MOSFET (metal-oxide-semiconductor fi ...