HDU5112【水】

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e4+10;

struct asd{
    double time;
    double x;
};
asd d[N];
int n;

bool cmp(asd a,asd b)
{
    return a.time<b.time;
}

int main()
{
    int T;
    int cas=1;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d",&n);
        for(int i=0;i<n;i++)
            scanf("%lf%lf",&d[i].time,&d[i].x);
        sort(d,d+n,cmp);
        double ans=0;
        for(int i=1;i<n;i++)
        {
            double tmp=fabs(d[i].x-d[i-1].x)/(d[i].time-d[i-1].time);
            if(tmp>ans)
                ans=tmp;
        }

        printf("Case #%d: ",cas++);
        printf("%.2lf
",ans);
    }
    return 0;
}
原文地址:https://www.cnblogs.com/keyboarder-zsq/p/5934776.html