1001 A Curious Matt

求一段时间内的速度单位时间变化量,其实就是直接求出单位时间内的,如果某段时间能达到最大那么这段时间内必定有一个或一小段单位时间内速度变化是最大的即局部能达到最大,比较水就是格式上有点坑,谜之wa了好几发

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <string.h>
 4 #include <math.h>
 5 #include <algorithm>
 6 #include <iostream>
 7 typedef long long ll;
 8 using namespace std;
 9
10
11 struct Node
12 {
13     ll t,x;
14  }p[100005];
15
16  int cmp(Node a,Node b)
17  {
18      return a.t<b.t;
19  }
20
21  int main()
22  {
23      int cas,n,i;
24      scanf("%d",&cas);
25      for(i=1;i<=cas;i++)
26      {
27          scanf("%d",&n);
28          for(int j=0;j<n;j++)
29              scanf("%lld %lld",&p[j].t,&p[j].x);
30          sort(p,p+n,cmp);
31
32          double max=abs(p[1].x-p[0].x)/(p[1].t-p[0].t);
33
34          for(int j=1;j<n;j++)
35          {
36              if((abs(p[j].x-p[j-1].x)/(p[j].t-p[j-1].t))>max)
37                 max=1.0*abs(p[j].x-p[j-1].x)/(p[j].t-p[j-1].t);
38          }
39         printf("Case #%d: %.2lf\n",i,max);
40     }
41      return 0;
42  }
时间: 2024-09-30 07:03:47

1001 A Curious Matt的相关文章

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 Problem Description There is a curious man called Matt. One day, Matt's best friend Ted is wa

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): 64    Accepted Submission(s): 49 Problem Description There is a curious man called Matt. One day, Matt's best friend Ted is wand

HDU5112 A Curious Matt

A Curious Matt Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Others) Total Submission(s): 25    Accepted Submission(s): 25 Problem Description There is a curious man called Matt. One day, Matt's best friend Ted is wand

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): 0    Accepted Submission(s): 0 Problem Description There is a curious man called Matt. One day, Matt's best friend Ted is wander

A Curious Matt(2014ACM/ICPC亚洲区北京站-A)

A Curious Matt Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Others) Total Submission(s): 0    Accepted Submission(s): 0 Problem Description There is a curious man called Matt. One day, Matt's best friend Ted is wander

2014ACM/ICPC亚洲区北京站-A Curious Matt

A Curious Matt Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others) Total Submission(s): 0 Accepted Submission(s): 0 Problem Description There is a curious man called Matt. One day, Matt's best friend Ted is wandering on

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 Problem Description There is a curious man called Matt. One day, Matt's best friend Ted is w

水题:HDU 5112 A Curious Matt

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’

hdu 5112 A Curious Matt (水题)

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