Advertisement
erfanul007

Untitled

Nov 25th, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int T,i;
  5. freopen("input.txt","r",stdin);
  6. scanf("%d",&T);
  7. for(i=1;i<=T;i++){
  8. int n,j,k;
  9. long long int t[100009],d[100009],temp,t1,d1;
  10. scanf("%d",&n);
  11. for(j=1;j<=n;j++){
  12. scanf("%d %d",&t[j],&d[j]);
  13. }
  14. for(j=1;j<=n;j++){
  15. for(k=j+1;k<=n;k++){
  16. if(t[j]>t[k]){
  17. temp=t[j];
  18. t[j]=t[k];
  19. t[k]=temp;
  20. temp=d[j];
  21. d[j]=d[k];
  22. d[k]=temp;
  23. }
  24. }
  25. }
  26. double max=0,v;
  27. for(j=2;j<=n;j++){
  28. t1=t[j]-t[j-1];
  29. d1=d[j]-d[j-1];
  30. if(d1<0)
  31. d1=-d1;
  32. v=(float)d1/t1;
  33. if(max<v)
  34. max=v;
  35. }
  36. printf("Case #%d: %.2lf\n",i,max);
  37. }
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement