Advertisement
Guest User

решение при d = 0

a guest
Aug 18th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <fstream>
  2. #include <vector>
  3. #include <string>
  4. #include <cmath>
  5. #include <algorithm>
  6.  
  7. using namespace std;
  8.  
  9. int main() {
  10. ifstream in("input.txt");
  11. ofstream out("output.txt");
  12. int d, n, res;
  13. double v, d_res = 0;
  14. in >> v >> d >> n;
  15. vector<int> x(n), time(n);
  16. string t;
  17. for (int i = 0; i < n; i++) {
  18. in >> x[i] >> t;
  19. time[i] += ((int)t[0] - 48) * 600 + ((int)t[1] - 48) * 60 + ((int)t[3] - 48) * 10 + ((int)t[4] - 48);
  20. }
  21. if (d == 0) {
  22. d_res += max((double)time[n-1], x[n - 1] / v);
  23. for (int i = n - 2; i >= 0; i--) {
  24. d_res = max((double)time[i], d_res + (double)(x[i + 1] - x[i]) / v);
  25. }
  26. d_res += (double)x[0] / v;
  27. }
  28. else {
  29.  
  30. }
  31. res = ceil(d_res);
  32. out << res / 600;
  33. res %= 600;
  34. out << res / 60 << ":";
  35. res %= 60;
  36. out << res / 10;
  37. res %= 10;
  38. out << res;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement