题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5112
解题报告:扫一遍
1 #include2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 const int maxn = 1e6+5; 8 9 struct node10 {11 double t,x;12 }rec[maxn];13 double Max(double a,double b)14 {15 return a > b? a : b;16 }17 bool cmp(node a,node b)18 {19 return a.t < b.t;20 }21 double Fabs(double d)22 {23 return d > 0? d:-1.0*d;24 }25 int main()26 {27 int T,n,kase = 1;28 scanf("%d",&T);29 while(T--)30 {31 scanf("%d",&n);32 for(int i = 0;i < n;++i)33 scanf("%lf%lf",&rec[i].t,&rec[i].x);34 sort(rec,rec+n,cmp);35 double ans = 0;36 for(int i = 1;i < n;++i)37 ans = Max(ans,Fabs(rec[i].x-rec[i-1].x) / (rec[i].t - rec[i-1].t));38 printf("Case #%d: %.2lf\n",kase++,ans);39 }40 return 0;41 }