给出某个时刻对应的速度 求出相邻时刻的平均速度 输出最大值
Sample Input23 // n2 2 //t v1 13 430 31 52 0Sample Output
Case #1: 2.00Case #2: 5.00
1 # include2 # include 3 # include 4 # include 5 # include 6 # include 7 # include 8 # include 9 # define LL long long10 using namespace std ;11 12 struct point13 {14 int t ;15 int v ;16 }a[10010];17 18 bool cmp(point x , point y)19 {20 return x.t < y.t ;21 }22 23 int main()24 {25 //freopen("in.txt","r",stdin) ;26 int T ;27 scanf("%d" , &T) ;28 int Case = 0 ;29 while(T--)30 {31 int n , i ;32 Case++ ;33 double MAX = 0 ;34 scanf("%d" , &n) ;35 for (i = 0 ; i < n ; i++)36 scanf("%d %d" , &a[i].t , &a[i].v) ;37 sort(a , a+n , cmp) ;38 for (i = 0 ; i < n-1 ; i++)39 {40 double ans = fabs((a[i+1].v - a[i].v)*1.0/(a[i+1].t - a[i].t)*1.0) ;41 if (ans > MAX)42 MAX = ans ;43 }44 printf("Case #%d: %.2lf\n" , Case , MAX) ;45 46 }47 48 return 0 ;49 }