GastonFontenla

Timus: 1821 - Biathlon

Jun 5th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <set>
  4. #include <vector>
  5. #include <algorithm>
  6.  
  7. #define ii make_pair
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13.     int n;
  14.     cin >> n;
  15.  
  16.     vector <pair<pair<int, int>, pair<int, int> > > t(n);
  17.     vector <pair<pair<int, int>, pair<int, int> > > f(n);
  18.     vector <string> nom(n);
  19.  
  20.     for(int i=0; i<n; i++)
  21.     {
  22.         cin >> nom[i];
  23.         scanf("%d:%d.%d", &t[i].first.first, &t[i].first.second, &t[i].second.first);
  24.         t[i].second.second = i;
  25.         f[i].second.second = i;
  26.  
  27.         f[i].first.first = t[i].first.first;
  28.         f[i].first.second = t[i].first.second + i*30;
  29.         f[i].second.first = t[i].second.first;
  30.         if(f[i].first.second > 59)
  31.         {
  32.             f[i].first.first += (f[i].first.second / 60);
  33.             f[i].first.second %= 60;
  34.         }
  35.     }
  36.  
  37.     sort(f.begin(), f.end());
  38.  
  39.     set<string> resultados;
  40.  
  41.     pair<pair<int, int>, pair<int, int> > mejorTiempo;
  42.  
  43.     mejorTiempo = ii(ii(999999, 999999), ii(999999, 999999));
  44.  
  45.     for(int i=0; i<n; i++)
  46.     {
  47.         if(t[f[i].second.second] < mejorTiempo)
  48.         {
  49.             resultados.insert(nom[f[i].second.second]);
  50.             mejorTiempo = t[f[i].second.second];
  51.         }
  52.     }
  53.  
  54.     cout << resultados.size() << endl;
  55.     for(auto i:resultados)
  56.         cout << i << endl;
  57.  
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment