Advertisement
erfanul007

LA 7058

Nov 26th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int c[1000009];
  4. int main()
  5. {
  6. int T;
  7. scanf("%d",&T);
  8. for(int i=1;i<=T;i++){
  9. vector<int>vt;
  10. int a,n;
  11. scanf("%d",&n);
  12. for(int j=0;j<n;j++){
  13. scanf("%d",&a);
  14. scanf("%d",&c[a]);
  15. vt.push_back(a);
  16. }
  17. sort(vt.begin(),vt.end());
  18. int t,d;
  19. double v,mx=0;
  20. for(int j=1;j<n;j++){
  21. t=vt[j]-vt[j-1];
  22. if(t<0)
  23. t=-t;
  24. d=c[vt[j]]-c[vt[j-1]];
  25. if(d<0)
  26. d=-d;
  27. v=(double)d/t;
  28. if(mx<v)
  29. mx=v;
  30. }
  31. printf("Case #%d: %.2lf\n",i,mx);
  32. }
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement