Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <math.h>
- #include <vector>
- #include <map>
- #include <set>
- #include <queue>
- #include <algorithm>
- #include <string>
- using namespace std;
- struct od
- {
- int l;
- int h;
- char f;
- int m;
- } od[1400];
- int main()
- {
- int v, d, n, count = 0, suml;
- double time = 0;
- bool check = false;
- cin >> v >> d >> n;
- cin >> od[0].l >> od[0].h >> od[0].f >> od[0].m;
- suml = od[0].l;
- for (int i = 1; i < n; i++)
- {
- cin >> od[i].l >> od[i].h >> od[i].f >> od[i].m;
- od[i].l -= od[i-1].l;
- suml += od[i].l;
- }
- for (int i = 0; i < n; i++)
- {
- time += double(od[i].l) / v;
- if (time >= od[i].h*60 + od[i].m)
- {
- time += d;
- count++;
- }
- if (i == (n-1) && od[i].h*60 + od[i].m > time)
- check = true;
- }
- if (!check)
- {
- time += double(suml) / v;
- time += (n - count) * d;
- }
- else
- {
- time = od[n-1].h * 60 + od[n-1].m;
- time += n * d;
- time += double(suml / v)*2;
- }
- int time2 = ceil(time);
- if (time2 / 60 < 10)
- if (time2 % 60 > 10)
- cout << "0" << time2 / 60 << ":" << time2 % 60;
- else
- cout << "0" << time2 / 60 << ":" <<"0" << time2 % 60;
- else
- if (time2 % 60 > 10)
- cout << time2 / 60 << ":" << time2 % 60;
- else
- cout << time2 / 60 << ":" << "0" << time2 % 60;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement