admin管理员组

文章数量:1612099

//给出每个点在每个时间的位置 , 找出其最大的可能的速度
//由于其位置在一条直线上 
//所以直接对时间排序,然后对相邻的两个点直接求
//最大的速度 ,  
//画一下图就能知道最大速度一定在这上面
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std ;
const int maxn = 10010 ;
pair<int , int> a[maxn] ;
int main()
{
    int T ;
    int cas = 0 ;
    scanf("%d" , &T) ;
    while(T--)
    {
        int n ;
        scanf("%d" , &n) ;
        for(int i = 1;i <= n;i++)
        {
            int t , x ;
            scanf("%d%d" , &t , &x) ;
            a[i] = make_pair(t , x) ;
        }
        sort(a+1 , a+1+n) ;
        double ans = 0 ;
        for(int i = 2;i <= n ;i++)
        ans = max(ans , abs((a[i].second-a[i-1].second)*1.0)/abs((a[i].first-a[i-1].first)*1.0)) ;
        printf("Case #%d: " , ++cas) ;
        printf("%.2lf\n" , ans) ;
    }
    return 0 ;
}


本文标签: curioushdu5112A水题Matt