Advertisement
Farjana_akter

Untitled

Feb 11th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. long long int test,i,temp1,temp2,j,k,l,n,t[10000+5],s[10000+5],a,b,c,d,e,f;
  7. cin>>test;
  8. for(l=1;l<=test;l++)
  9. {
  10. cin>>n;
  11. for(i=0;i<n;i++)
  12. {
  13. cin>>t[i]>>s[i];
  14. }
  15. for(i=0;i<n;i++)
  16. {
  17. for(j=i+1;j<n;j++)
  18. {
  19. if(t[i]>t[j])
  20. {
  21. temp1=t[i];
  22. t[i]=t[j];
  23. t[j]=temp1;
  24.  
  25. temp2=s[i];
  26. s[i]=s[j];
  27. s[j]=temp2;
  28. }
  29. }
  30. }
  31. double max=0.0;
  32. for(i=1;i<n;i++)
  33. {
  34. int time=abs(t[i]-t[i-1]);
  35. int spot=abs(s[i]-s[i-1]);
  36. double ans= (double)spot/time;
  37. if(ans>max)
  38. max=ans;
  39. }
  40. printf("Case #%lld: %.2lf\n",l,max);
  41. }
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement