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 ...
随机推荐
- BZOJ2427: [HAOI2010]软件安装 tarjan+树形背包
分析: 一开始我以为是裸的树形背包...之后被告知这东西...可能有环...什么!有环! 有环就搞掉就就可以了...tarjan缩点...建图记得建立从i到d[i]之后跑tarjan,因为这样才能判断 ...
- 20155236范晨歌_Web安全基础实践
20155236范晨歌_Web安全基础实践 目录 实践目标 WebGoat BurpSuite Injection Flaws Cross-Site Scripting (XSS) 总结 实践目标 ( ...
- mount状态下表空间情报试验
SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.SQL> sta ...
- C++中的this和Python的self对比
Python,当实例对象调用函数(函数其实都是属于类空间的)的时候,系统会自动将对象本身传入 函数在定义时的第一个变量一般是self.(但self并不是关键字,用其他名字也可以) 定义 ...
- mfc CFileDialog类
知识点: CFileDialog类 SetBitmap LoadImage 动态显示图片 一.CFileDialog类 构造函数 CFileDialog( BOOL bOpenFileDialog, ...
- 解决 配置springmvc拦截所有请求后请求静态资源404的问题
<servlet-mapping> <servlet-name>spring-servlet</servlet-name> <url-pattern>/ ...
- javascript source map 的使用
之前发现VS.NET会为压缩的js文添加一个与文件名同名的.map文件,一直没有搞懂他是用来做什么的,直接删除掉运行时浏览器又会报错,后来google了一直才真正搞懂了这个小小的map文件背后的巨大意 ...
- Kosaraju算法、Tarjan算法分析及证明--强连通分量的线性算法
一.背景介绍 强连通分量是有向图中的一个子图,在该子图中,所有的节点都可以沿着某条路径访问其他节点.强连通性是一种非常重要的等价抽象,因为它满足 自反性:顶点V和它本身是强连通的 对称性:如果顶点V和 ...
- C#_Winfrom将浏览器生成Image
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- PS官方正式中文版(搬砖分享)
https://pan.baidu.com/s/1c3IdQq0 PS官方正式中文版(搬砖分享) 注意事项: 1.安装开始前请先断网,在成功破解激活前请全程断网: 2.安装完成后先试运行软件一次,然后 ...