水题:HDU 5112 A Curious Matt
Description
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
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 t i and x i (0 ≤ t i, x i ≤ 10 6), 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 t i would be distinct.
Output
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 <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
const int N=;
int tim[N],pos[N],p[N];
bool cmp(int x,int y){
return tim[x]<tim[y];
}
int main(){
int T,n,cas=;
double ans;
scanf("%d",&T);
while(T--){
scanf("%d",&n);
for(int i=;i<=n;i++){
scanf("%d%d",&tim[i],&pos[i]);
p[i]=i;
}
sort(p+,p+n+,cmp);
ans=0.0;
for(int i=;i<=n;i++)
ans=max(ans,fabs(pos[p[i]]-pos[p[i-]])/fabs(tim[p[i]]-tim[p[i-]]));
printf("Case #%d: %.2f\n",++cas,ans);
}
return ;
}
水题:HDU 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) ...
- hdoj 5112 A Curious Matt
A Curious Matt Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others) ...
- HDU 5120 A Curious Matt(2014北京赛区现场赛A题 简单模拟)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5112 解题报告:扫一遍 #include<cstdio> #include<cstr ...
- 水题~~~~HDU 4788
Description Yesterday your dear cousin Coach Pang gave you a new 100MB hard disk drive (HDD) as a gi ...
- 又是一道水题 hdu背包
Problem Description 电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额.如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负) ...
- hdu 2393:Higher Math(计算几何,水题)
Higher Math Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- HDU 5832 A water problem(某水题)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
随机推荐
- Bootstrap-全局css样式之按钮
这里所说的按钮只是Bootstrap设计的能使标签或元素呈现按钮样式的属性,所以为 <a>.<button> 或 <input> 元素添加按钮类(button cl ...
- 概述ASP.NET缓存机制
PetShop之ASP.NET缓存机制 如果对微型计算机硬件系统有足够的了解,那么我们对于Cache这个名词一定是耳熟能详的.在CPU以及主板的芯片中,都引入了这种名为高速缓冲存储器(Cache)的技 ...
- Windows I/O模型、同步/异步、阻塞/非阻塞
转载自:http://www.cppblog.com/tx7do/articles/5954.html 同步 所谓同步,就是在发出一个功能调用时,在没有得到结果之前,该调用就不返回.按照这个定义,其实 ...
- 1.RABBITMQ 入门 - WINDOWS - 获取,安装,配置
一. 背景: 公司项目有所改动,要求微信(移动端调用的接口),日志接口换位log4net,全部改成以rabbitMQ作为服务支持, 二.本地环境: windows 10 enterpr ...
- 数据库msqlserver的几种类型及解决MSSQLServer服务启动不了的问题
从08年开始学习了sqlserver数据库之后,就一直以为sqlserver只有版本的区分,没有类型的差异:总以为从Sql2000. sql2005到sql2008.sql2012,微软出口的数据库, ...
- 如何获得Windows 8中已记住的WIFI的明文密码
网上很流行的一种查看WIFI密码明文的方法,如下: 今天遇到了一种状况,就是如果不连WIFI的情况我能抓到这个密码吗?(实在不想开口问同事密码多少,只能苦逼的自己想办法了o(︶︿︶)o ) 答案当然是 ...
- 恢复误删的procedure
如果10分钟不小心刚刚误删了一个procedure,又没保存脚本,现在如何恢复? drop procedure必然delete dba_source,delete 当然会想到闪回查询 sql>c ...
- easyui中datagrid标题居中内容居左实现方式
easyui中的datagrid使用起来,确实还是挺轻巧方便,但是其中也有不少的问题,尤其遇到客户的一些特殊的需求时往往实现得不是很好.这个时候就需要我们自己动手来修改easyui的源码了.easyu ...
- 三步走起 提升 iOS 审核通过率 上篇
<ignore_js_op> Bugly 技术干货系列内容主要涉及移动开发方向,是由 Bugly 邀请腾讯内部各位技术大咖,通过日常工作经验的总结以及感悟撰写而成,内容均属原创,转载请标明 ...
- Ajax and JSON
Ajax (核心是XMLHttpRequest对象) 1.XMLHttpRequest对象: request=new XMLHttpRequest() 支持Firefox opera Safari ...