Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <iostream>
- #include <string>
- using namespace std;
- string name, s, timer1, timer2, bestname;
- int h1, h2, m1, m2, all_time, result = int(1e9), n, cnt;
- int main()
- {
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- cin >> n;
- for (int i = 0; i < n; i++)
- {
- cnt = 0;
- name = "";
- for (;;)
- {
- cin >> s;
- name += s;
- for (int j = 0; j < s.size(); j++)
- if (s[j] == '"')
- cnt++;
- if (cnt == 2) break;
- name += " ";
- }
- cin >> timer1 >> timer2;
- sscanf(timer1.c_str(), "%d:%d ", &h1, &m1);
- sscanf(timer2.c_str(), "%d:%d ", &h2, &m2);
- all_time = (h2 * 60 + m2) - (h1 * 60 + m1);
- if (all_time <= 0) all_time += 24 * 60;
- if (all_time < result)
- {
- result = all_time;
- bestname = name;
- }
- }
- cout << "The fastest train is " << bestname <<".\nIt's speed is " << int(650.0 / result * 60 + 0.5) << " km/h, approximately.";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement