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 ...
随机推荐
- SEO优化上首页之搜索引擎排名规则
搜索引擎建立索引的网页数以万亿计,用户搜索的关键词也是海量,如果每个用户提交搜索请求后,搜索引擎都去数以万亿的索引中重新排名网页,效率将非常低下.根据2-8法则,80%是查询是集中在相同的20%内容上 ...
- POJ2488&&3083&&3009&&1321&&2251&&2049
刷完了大力数据结构(水比数据结构专题)后又开始搞无脑搜索专题了 这次的标签是DFS(这TM的到现在了谁还不会) 2488 跳马问题:给出一个棋盘,让你求一个方案使一匹马能花最短的时间不重复不遗漏地跳完 ...
- 汇编 REPNE/REPNZ 指令,SCASB 指令
知识点: REPNE/REPNZ 指令 SCASB 指令 一.SCASB 指令 cmp byte ptr [edi],al //对标志位的影响相当于sub指令 //同时还会修改寄存器EDI的值:如 ...
- Arcgis安装要素
1. ArcGIS安装过程中需将用户名改为计算机名,该计算机名称时需要新建对话框. 2. ArcGIS Server安装过程中要设置ArcGISWebServices用户的读写权限,即设置ASP.NE ...
- 未能使用“Csc”任务的输入参数初始化该任务
今天.NetCore2.1版本,建立Asp.net Core web应用程序项目时,报以下错误: 未能使用“Csc”任务的输入参数初始化该任务. “Csc”任务不支持“SharedCompilatio ...
- android studio 下载 sdk 失败
android studio 打开项目出现以下错误时,点击去安装,会提示"All packages are not available for download" 错误. 解决办法 ...
- Python魔术世界 1 如何使用Visual Studio在WIN10中一键安装Python3入门编程环境并测试Django
本文通过VS安装Python和Django的环境,创建了一个Web程序,前后5分钟的操作,让你快速入门Python的编程世界,各种Python和Django的概念会在实战中给你娓娓道来. Django ...
- java Script复习总结
一:基础知识 1.JavaScript语言的历史 l 早期名称:livescript l 开发公司:网景公司(netscape) 2.JavaScript语言的基本特点 l 基于对象 l 事件 ...
- OpenGL学习(3)——Shader
之前已经接触过Vertex Shader和Fragment Shader,这次学习如何编写Shader并封装成类. Shader源码主要有四部分: 版本声明 #version xxx core: 使用 ...
- 部署jar项目常用命令
netstat -tunlp | grep ×× 查询出端口为××在运行应用的线程ip kill -9 ×× 关闭线程ip 为 ××的应用 rm -f ××.jar ...