hdoj 5112 A Curious Matt
A Curious Matt
Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others)
Total Submission(s): 1338 Accepted Submission(s):
735
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.
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<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#define MAX 10100
#define DD double
using namespace std;
struct node
{
int time,pos;
}s[MAX];
bool cmp(node a,node b)
{
return a.time<b.time;
}
int main()
{
int t,n,m,i,j,k;
scanf("%d",&t);
k=0;
while(t--)
{
scanf("%d",&n);
DD sum=0,ans=0;
for(i=0;i<n;i++)
scanf("%d%d",&s[i].time,&s[i].pos);
sort(s,s+n,cmp);
for(i=0;i<n-1;i++)
{
DD sum=(s[i+1].pos-s[i].pos)*1.0/(s[i+1].time-s[i].time);
ans=max(fabs(sum),ans);
}
printf("Case #%d: %.2lf\n",++k,ans);
}
return 0;
}
hdoj 5112 A Curious Matt的更多相关文章
- 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 ...
- HDU 5112 A Curious Matt (2014ACM/ICPC亚洲区北京站-重现赛)
A Curious Matt Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others) ...
- 水题:HDU 5112 A Curious Matt
Description There is a curious man called Matt. One day, Matt's best friend Ted is wandering on the ...
- HDU 5120 A Curious Matt(2014北京赛区现场赛A题 简单模拟)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5112 解题报告:扫一遍 #include<cstdio> #include<cstr ...
- 2014ACM/ICPC亚洲区北京站
1001 A Curious Matt 求一段时间内的速度单位时间变化量,其实就是直接求出单位时间内的,如果某段时间能达到最大那么这段时间内必定有一个或一小段单位时间内速度变化是最大的即局部能达到最 ...
- 2014年亚洲区域赛北京赛区现场赛A,D,H,I,K题解(hdu5112,5115,5119,5220,5122)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud 下午在HDU上打了一下今年北京区域赛的重现,过了5题,看来单挑只能拿拿铜牌,呜呜. ...
- 2014 ACM/ICPC Asia Regional Beijing Site
1001 A Curious Matt 1002 Black And White 1003 Collision 1004 Dire Wolf 1005 Everlasting L 1006 Fluor ...
- hdoj 5119 Happy Matt Friends 背包DP
Happy Matt Friends Time Limit: 6000/6000 MS (Java/Others) Memory Limit: 510000/510000 K (Java/Others ...
随机推荐
- 视频边下边播--缓存播放数据流-b
google搜索“iOS视频变下边播”,有好几篇博客写到了实现方法,其实只有一篇,其他都是copy的,不过他们都是使用的本地代理服务器的方式. 原理很简单,但是缺点也很明显,需要自己写一个本地代理服务 ...
- 在asp.net中如何自己编写highcharts图表导出到自己的服务器上来
1.准备工作:网上下载highcharts导出的关键dll. 1).Svg.dll:因为highcharts的格式其实就是一个xml,采用svg的方式画图: 2).itextsha ...
- ANDROID_MARS学习笔记_S01原始版_006_ListView
一.代码1.xml(1)main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayo ...
- 《ArcGIS Engine+C#实例开发教程》第七讲 图层符号选择器的实现2
原文:<ArcGIS Engine+C#实例开发教程>第七讲 图层符号选择器的实现2 摘要:在第七讲 图层符号选择器的实现的第一阶段中,我们完成了符号选择器窗体的创建与调用.在第二阶段中, ...
- grep简单常用的语法介绍
说明: grep -n 关键字 查询的文档 ->-n表示打印行号 grep -c 关键字 查询的文档1 查询的文档2 ->-c表示输出匹配行的数目,而不是输出匹配的行. grep -rn ...
- hadoop异常:java.lang.RuntimeException: java.lang.NoSuchMethodException
出现异常的程序大致框架是这样的: public class getMaxTemperature extends Configured implements Tool { ... class MaxTe ...
- BZOJ_1612_[Usaco2008_Jan]_Cow_Contest_奶牛的比赛_(dfs)
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1612 \(n\)头奶牛比赛,给出一些胜负情况,问可以确定多少头奶牛的排名. 分析 无论胜负,只 ...
- BZOJ_2049_[Sdoi_2008]_Cave_洞穴勘测_(LCT/并查集)
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=2049 给出一个森林,起始互不相连,现在有link和cut两种操作,问x,y是否在一棵树里. 分 ...
- 调试UnhandledExceptionFilter
kernel32!UnhandledExceptionFilter通过判断当前进程是否附加了调试器,如果附加,就把异常交给调试器,如果没有,就把异常交给进程的UnhandledExceptionFil ...
- sql点滴39—解决数据库日志文件过大的问题
随着数据库使用时间增长,日志文件也在不停的增大,这里介绍几种方法减小这个文件的方法. 1.直接删除log文件(一般不建议) 分离数据库.分离数据库之前一定要做好数据库的全备份,选择数据库——右键——任 ...