fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. typedef pair<long double,int> pdc;
  7.  
  8. pdc FTime[2000100];
  9. int PointR = 0;
  10.  
  11.  
  12. int main(){
  13. int n,w,u,v;
  14. long double t1,t2;
  15. cin >> n >> w >> u >> v >> t1 >> t2;
  16.  
  17. int nn;
  18. char z;
  19. int pos,len;
  20. int uu;
  21. long double p1 = (w+0.0)/v;
  22. for (int i=0;i<n;i++){
  23. cin >> z >> nn;
  24. if (z == 'E')
  25. uu = - u;
  26. else uu = u;
  27. for (int j=0;j<nn;j++){
  28. cin >> len >> pos;
  29.  
  30. FTime[PointR++] = pdc( (pos+0.0)/uu - p1*i - p1,1);
  31. if (z == 'E') pos-=len;
  32. else pos+=len;
  33.  
  34. FTime[PointR++] = pdc( (pos+0.0)/uu - p1*i,-1);
  35. }
  36. }
  37. sort(FTime,FTime+PointR);
  38. long double ans = 0;
  39. int balance = 0;
  40. long double tpred = 0;
  41. for (int i=0;i< PointR;i++){
  42. if (!balance)
  43. ans = max(ans, min(t2,FTime[i].first) - max(t1, tpred) );
  44. //clog << balance<<" "<<FTime[i].first<<" "<<FTime[i].second<<" --- "<<ans<<endl;
  45. balance += FTime[i].second;
  46. tpred = FTime[i].first;
  47. }
  48. if (FTime[PointR-1].first < t2)
  49. ans = max(ans, t2 - FTime[PointR-1].first );
  50. cout<< setprecision(15) << ans<<endl;
  51. }
Success #stdin #stdout 0.04s 34360KB
stdin
Standard input is empty
stdout
0