Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <string>
- #include <map>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int string_to_int(string a)
- {
- reverse(a.begin(), a.end());
- int d = 1;
- int res = 0;
- for(int i = 0; i < a.size(); i++)
- {
- res += (a[i] - '0') * d;
- d *= 10;
- }
- return res;
- }
- double res_time(string a, int num)
- {
- double minutes = string_to_int(a.substr(0, 2));
- double seconds = (double)string_to_int(a.substr(3, 2)) + ((double)string_to_int(a.substr(6, 1)) / 10);
- double res = minutes * 60 + seconds - num * 30;
- return res;
- }
- struct sman
- {
- int time, start;
- string name;
- sman(): time(), start(), name(){}
- sman(int _time, int _start, string _name): time(_time), start(_start), name(_name){}
- };
- bool cmp (sman a, sman b)
- {
- return a.time < b.time;
- }
- int main()
- {
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- int n;
- cin >> n;
- vector<sman> for_sort;
- map<string, int> res;
- map<int, string> finish;
- for(int i = 0; i < n; i++)
- {
- string name;
- cin >> name;
- string time;
- cin >> time;
- int t = res_time(time, -i);
- for_sort.push_back(sman(t, i, name));
- }
- sort(for_sort.begin(), for_sort.end(), cmp);
- for(int i = 0; i < n; i++)
- {
- int b = for_sort[i].time - for_sort[i].start * 2 * 30;
- finish[b] = for_sort[i].name;
- if(finish.begin()->first == b)
- res[finish[b]]++;
- }
- cout << res.size() << endl;
- for(auto it = res.begin(); it != res.end(); it++)
- cout << it->first << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement