HDU 5112 A Curious Matt (2014ACM/ICPC亚洲区北京站-重现赛)

时间:2023-01-12 13:11:22

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

Problem Description
There is a curious man called Matt.

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.

 
Input
The first line contains only one integer T, which
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.

 
Output
For each test case, output a single line “Case #x: y”,
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.
 
Sample Input
2
3
2 2
1 1
3 4
3
0 3
1 5
2 0
 
Sample Output
Case #1: 2.00
Case #2: 5.00
Hint

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亚洲区北京站-重现赛)的更多相关文章

  1. HDU 5127&period;Dogs&&num;39&semi; Candies-STL&lpar;vector&rpar;神奇的题,set过不了 &lpar;2014ACM&sol;ICPC亚洲区广州站-重现赛(感谢华工和北大)&rpar;

    周六周末组队训练赛. Dogs' Candies Time Limit: 30000/30000 MS (Java/Others)    Memory Limit: 512000/512000 K ( ...

  2. HDU 5135&period;Little Zu Chongzhi&&num;39&semi;s Triangles-字符串 &lpar;2014ACM&sol;ICPC亚洲区广州站-重现赛&rpar;

    Little Zu Chongzhi's Triangles Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 512000/512000 ...

  3. HDU 5131&period;Song Jiang&&num;39&semi;s rank list &lpar;2014ACM&sol;ICPC亚洲区广州站-重现赛&rpar;

    Song Jiang's rank list Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java ...

  4. Hdu OJ 5115 Dire Wolf &lpar;2014ACM&sol;ICPC亚洲区北京站&rpar; &lpar;动态规划-区间dp)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5115 题目大意:前面有n头狼并列排成一排, 每一头狼都有两个属性--基础攻击力和buff加成, 每一头 ...

  5. hdu 5112 A Curious Matt

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5112 A Curious Matt Description There is a curious ma ...

  6. HDU 5112 A Curious Matt 水题

    A Curious Matt Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid ...

  7. 2014ACM&sol;ICPC亚洲区北京站

    1001  A Curious Matt 求一段时间内的速度单位时间变化量,其实就是直接求出单位时间内的,如果某段时间能达到最大那么这段时间内必定有一个或一小段单位时间内速度变化是最大的即局部能达到最 ...

  8. HDU-5532&sol;&sol;2015ACM&sol;ICPC亚洲区长春站-重现赛-F - Almost Sorted Array&sol;&comma;哈哈,水一把区域赛的题~~

    F - Almost Sorted Array Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & ...

  9. 水题:HDU 5112 A Curious Matt

    Description There is a curious man called Matt. One day, Matt's best friend Ted is wandering on the ...

随机推荐

  1. 关于JSF中immediate属性的总结&lpar;二&rpar;

    The immediate attribute in JSF is commonly misunderstood. If you don't believe me, check out Stack O ...

  2. arm指令周期

    1.大部分算术运算和逻辑运算指令都是单周期的,例如加法.减法.位级运算和移位 2.乘法指令根据操作数位数的不同,从2-5个周期都有可能. 3.无条件跳转语句和跳转语句成功跳转,需要重新填充流水线,因此 ...

  3. 自制Unity小游戏TankHero-2D&lpar;3&rpar;开始玩起来

    自制Unity小游戏TankHero-2D(3)开始玩起来 我在做这样一个坦克游戏,是仿照(http://game.kid.qq.com/a/20140221/028931.htm)这个游戏制作的.仅 ...

  4. 扫描二维码下载安装apk的app

    将apk文件放到服务器上,下载链接直接生成二维码,用微信扫描时不能直接下载.页面只是刷新一下. 想实现微信扫描下载apk的app客户端,需要把下载链接做到一个网页上, 将网页生成一个二维码. 直接下载 ...

  5. DNS子域委派配置案例&lbrack;转载&rsqb;

    最近在研究linux dns 在51上面看见这篇文章,感觉讲的很透彻,随转载,方便以后自己查阅 原文地址:http://www.51osos.com/a/Linux_CentOS_RedHat/Lin ...

  6. ios开发——实用技术篇Swift&amp&semi;Swift调用C、C&plus;&plus;、Object

    Swift调用C.C++.Object 1.Swift调用C语言a,首先在项目中添加 CFile 文件命名为CHello,同时产生桥梁文件. b,创建之后的项目结构 b,在CHello.h文件中编写接 ...

  7. Redis系统学习 四、超越数据结构

    5种数据结构组成了Redis的基础,其他没有关联特定数据结构的命令也有很多.我们已经看过一些这样的命令:info,select,flushdb,multi,exec,discard,watch,和ke ...

  8. Go 自带的 http&sol;server&period;go 的连接解析 与 如何结合 master-worker 并发模式,提高单机并发能力

    作者:林冠宏 / 指尖下的幽灵 掘金:https://juejin.im/user/587f0dfe128fe100570ce2d8 博客:http://www.cnblogs.com/linguan ...

  9. c&plus;&plus;入门之浅拷贝和深拷贝

    关于这方面的知识:见一篇精辟博文:https://blog.csdn.net/feitianxuxue/article/details/9275979

  10. XXS level10

    (1)进入第十关发现无突破口,尝试从url中的keyword入手,也行不通,但可以从页面源代码看到有三个参数是隐藏的 (2)查看PHP源代码 <?php ini_set("displa ...