标签:des style blog io ar color os sp java
Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others)
1 #include<stdio.h> 2 #include<string.h> 3 #include<algorithm> 4 #include<iostream> 5 #include<cmath> 6 using namespace std; 7 8 struct node{ 9 int t, pos; 10 }q[10010]; 11 12 bool cmp(struct node x, struct node y) 13 { 14 if(x.t<y.t) 15 return 1; 16 else return 0; 17 } 18 19 int main() 20 { 21 int T, n, i, k=1; 22 double s[10010], maxx; 23 scanf("%d", &T); 24 while(T--) 25 { 26 maxx=-1; 27 scanf("%d", &n); 28 for(i=0; i<n; i++) 29 { 30 scanf("%d%d", &q[i].t, &q[i].pos); 31 } 32 sort(q, q+n, cmp); 33 for(i=0; i<n-1; i++) 34 { 35 s[i] = (double) ( (abs)(q[i+1].pos-q[i].pos) )/(q[i+1].t-q[i].t); 36 { 37 if(s[i]>maxx) 38 maxx=s[i]; 39 } 40 } 41 printf("Case #%d: %.2lf\n", k++, maxx); 42 } 43 return 0; 44 }
2014ACM/ICPC亚洲区北京站-A-(Curious Matt)
标签:des style blog io ar color os sp java
原文地址:http://www.cnblogs.com/6bing/p/4132320.html