Advertisement
erfanul007

Untitled

Nov 26th, 2018
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int T;
  6. freopen("input.txt","r",stdin);
  7. scanf("%d",&T);
  8. for(int i=1;i<=T;i++){
  9. vector<int>vt;
  10. int a,n,c[100009];
  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. printf("t: %d\n",t);
  25. d=c[vt[j]]-c[vt[j-1]];
  26. if(d<0)
  27. d=-d;
  28. printf("d: %d\n",d);
  29. v=(double)d/t;
  30. printf("v: %.2lf\n",v);
  31. if(mx<v)
  32. mx=v;
  33. }
  34. printf("Case #%d: %.2lf\n\n",i,mx);
  35. }
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement