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 ...
随机推荐
- keepalived 做全端口映射
global_defs { lvs_id BACKUP } vrrp_sync_group VGM { group { VI_1 } } vrrp_inst ...
- 一个将lambda字符串转化为lambda表达式的公共类
一个将lambda字符串转化为lambda表达式的公共类.StringToLambda 使用方式如下: var module = new Module(); url = url.ToLower();/ ...
- php安装后,再添加模块pdo_mysql,mysqli
windows下,是动态链接库.dll,linux下是.so. linux下,假设php安装在/usr/local/php,php的源码包放在/usr/local/php-5.6.15 去php源码包 ...
- Kafka 集群部署
kafka是一个分布式消息队列,需要依赖ZooKeeper,请先安装好zk集群 kafka安装包解压 $ -0.9.0.1.tgz $ -0.9.0.1 /usr/kafka $ cd /usr/ka ...
- sql语句之表间字段值复制遇到的一些问题--基于mysql
好久没来园子了,转眼2017已经到3月份了,前段时间一直忙没时间写博客(其实是自己懒),感觉内心好惭愧.昨天临下班前,技术老大突然对我说要改下表结构,问我能不能实现将一个表的字段值复制到另外一个表的某 ...
- 比较不错的Nosql文章
1. NoSQL简单介绍 2. NoSQL初探之人人都爱Redis:(1)Redis简介与简单安装 3. NoSQL初探之人人都爱Redis:(2)Redis API与常用数据类型简介 4. NoSQ ...
- [CF1007D]Ants[2-SAT+树剖+线段树优化建图]
题意 我们用路径 \((u, v)\) 表示一棵树上从结点 \(u\) 到结点 \(v\) 的最短路径. 给定一棵由 \(n\) 个结点构成的树.你需要用 \(m\) 种不同的颜色为这棵树的树边染色, ...
- Window下mysql环境配置问题整理
Window下mysql环境配置问题整理 参考如下链接. 无需安装解压版mysql包 创建选项配置 首次启动服务 用mysqld初始化目录 安装后设置和测试 启动服务错误信息 管理员模式打开cmd m ...
- webVR全景图多种方案实现(pannellum,aframe,Krpano,three,jquery-vrview)
前言 有一篇文章我说了H5实现全景图预览,全景视频播放的原理,有需要的小伙伴可以自行去看一下 今天我就拿出我的实践干货出来,本人实测实测过 需求 老板:我需要可以上传全景图片,然后手机网站上都可以36 ...
- Catlike学习笔记(1.1)-使用Unity实现一个钟表
最近发现『Catlike系列教程』觉得内容真的很赞,感觉有很多地方涉及到了我的知识盲点,如果真的可以照着做下来一遍的话应该收获颇丰.因为教程很长所以逐字翻译不太可能了(主要是翻译的太差).基本上就是把 ...