A Curious matttime limit:2000/2000 MS (java/others) Memory limit:512000/512000 K (java/others) total submission (s): 0 Accepted Submission (s): 0Problem Description There is a curious man called Matt. One day, Matt's best friend Ted was wandering on the non-negative half of the. Matt finds it interesting to know, the maximal speed Ted may reach. In order to does so, Matt takes records of Ted ' s position. Now Matt has a great deal of records. Please help him to find out the maximal speed Ted could reach, assuming Ted moves with a constant speed between Ive records. Input The first line contains only one integer T, which indicates the number of test cases. For each test case, the first line contains an integer N (2≤n≤10000), indicating the number of records. Each of the following N lines contains-integers ti and XI (0≤ti, xi≤106), indicating the time when this record is Taken and Ted ' s corresponding position. Note that records may unsorted bY time. It ' s guaranteed that all TI would is distinct. Output a single line "Case #x: Y", where x is the case number (starting from 1), and Y is the Maximal speed Ted may reach. The result should is rounded to both decimal places. Sample Input232 430 0 Sample Outputcase #1:2.00Case #2:5.00HintIn the? rst Sample, Ted moves from 2 to 4 in 1 time unit. The speed 2/1 is maximal. In the second sample, Ted moves from 5 to 0 in 1 time unit. The speed 5/1 is maximal. Statistic | Submit | Clarifications | Back
#include <cstdio> #include <cstring> #include <cmath> #include <cstdlib> #include <iostream > #include <algorithm> #include <queue> #include <stack>using namespace std;const int maxn=10010; struct record{int l,r;} A[maxn];bool CMP (record C,record D) {return C.L<D.L;} int main () {int t;scanf ("%d", &t), for (int k=1;k<=t;k++) {int n;scanf ("%d", &n), and for (int i=0;i<n;i++) {scanf ("%d%d", &A[I].L,&A[I].R); } sort (a,a+n,cmp);d ouble maximal=0;for (int i=0;i<n-1;i++) { if (double) (ABS (A[I+1].R-A[I].R)/abs (a[i+1].l-a [i].l) >maximal) { maximal= (double) abs (A[I+1].R-A[I].R)/abs (A[I+1].L-A[I].L); }} printf ("Case #%d:%.2lf\n", k,maximal);} return 0;}
2014ACM/ICPC Asia Beijing Station-a curious Matt