fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. double t1, t2, t3, T, T2;
  6. double v1, v2, v3, S;
  7. double s1, s2, s3;
  8.  
  9. cin >> t1 >> t2 >> t3;
  10. cin >> v1 >> v2 >> v3;
  11.  
  12. s1 = v1*t1;
  13. s2 = v2*t2;
  14. s3 = v3*t3;
  15. S = (s1 + s2 + s3)/2;
  16.  
  17. if ( (T = S/v1) <= t1) {
  18. cout << T << endl;
  19. return 0;
  20. } else {
  21. T = t1;
  22. }
  23.  
  24.  
  25. if ( (T2 = (S-s1)/v2) <= t2) {
  26. T+=T2;
  27. cout << T << endl;
  28. return 0;
  29. } else {
  30. T += t2;
  31. }
  32.  
  33. T += ((S-s1-s2)/v3);
  34. cout << T <<endl;
  35.  
  36. return 0;
  37. }
Success #stdin #stdout 0s 3432KB
stdin
4.5 75.9 3.124
100 0 0
stdout
2.25