标签:
Description
Input
Output
Sample Input
2 3 2 2 1 1 3 4 3 0 3 1 5 2 0
Sample Output
Case #1: 2.00 Case #2: 5.00
Hint
1 #include <algorithm> 2 #include <iostream> 3 #include <cstring> 4 #include <cstdio> 5 #include <cmath> 6 using namespace std; 7 const int N=1000010; 8 int tim[N],pos[N],p[N]; 9 bool cmp(int x,int y){ 10 return tim[x]<tim[y]; 11 } 12 int main(){ 13 int T,n,cas=0; 14 double ans; 15 scanf("%d",&T); 16 while(T--){ 17 scanf("%d",&n); 18 for(int i=1;i<=n;i++){ 19 scanf("%d%d",&tim[i],&pos[i]); 20 p[i]=i; 21 } 22 sort(p+1,p+n+1,cmp); 23 ans=0.0; 24 for(int i=2;i<=n;i++) 25 ans=max(ans,fabs(pos[p[i]]-pos[p[i-1]])/fabs(tim[p[i]]-tim[p[i-1]])); 26 printf("Case #%d: %.2f\n",++cas,ans); 27 } 28 return 0; 29 }
标签:
原文地址:http://www.cnblogs.com/TenderRun/p/5943355.html