Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <vector>
- #include <string>
- #include <cmath>
- #include <algorithm>
- using namespace std;
- int main() {
- ifstream in("input.txt");
- ofstream out("output.txt");
- int d, n, res;
- double v, d_res = 0;
- in >> v >> d >> n;
- vector<int> x(n), time(n);
- string t;
- for (int i = 0; i < n; i++) {
- in >> x[i] >> t;
- time[i] += ((int)t[0] - 48) * 600 + ((int)t[1] - 48) * 60 + ((int)t[3] - 48) * 10 + ((int)t[4] - 48);
- }
- if (d == 0) {
- d_res += max((double)time[n-1], x[n - 1] / v);
- for (int i = n - 2; i >= 0; i--) {
- d_res = max((double)time[i], d_res + (double)(x[i + 1] - x[i]) / v);
- }
- d_res += (double)x[0] / v;
- }
- else {
- }
- res = ceil(d_res);
- out << res / 600;
- res %= 600;
- out << res / 60 << ":";
- res %= 60;
- out << res / 10;
- res %= 10;
- out << res;
- }
Advertisement
Add Comment
Please, Sign In to add comment