Advertisement
CyberN00b

Untitled

Sep 7th, 2022
786
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.66 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define LINT long long int
  3. #define ULINT unsigned long long int
  4. #define INF 99999999999
  5.  
  6. using namespace std;
  7.  
  8. template<typename tmp>
  9. void input(vector<tmp>& vc) {
  10.     for (tmp& x : vc)
  11.         cin >> x;
  12. }
  13. template<typename tmp>
  14. void output(vector<tmp>& vc, string endll = " ", string endd = "\n") {
  15.     for (tmp& x : vc)
  16.         cout << x << endll;
  17.     cout << endd;
  18. }
  19.  
  20. int main(){
  21.     int n;
  22.     cin >> n;
  23.     map<string, pair<int, set<pair<pair<int, int>, string> > > > m;
  24.     for (int i = 0; i < n; ++i) {
  25.         string t;
  26.         cin >> t;
  27.         int tmp = t.find(',');
  28.         m.insert({t.substr(0, tmp),{stoi(t.substr(tmp + 1, t.size())), set<pair<pair<int, int>, string> >()}});
  29.     }
  30.     int a;
  31.     cin >> a;
  32.     for (int i = 0; i < a; ++i) {
  33.         string s;
  34.         cin >> s;
  35.         int tmp = s.find(','), tmp2;
  36.         string name, sport;
  37.         int sh, b;
  38.         name = s.substr(0, tmp);
  39.         tmp2 = tmp + 1;
  40.         tmp = s.find(',', tmp2);
  41.         sport = s.substr(tmp2, tmp - tmp2);
  42.         tmp2 = tmp + 1;
  43.         tmp = s.find(',', tmp2);
  44.         b = stoi(s.substr(tmp2, tmp - tmp2));
  45.         sh = stoi(s.substr(tmp + 1, s.size() - tmp));
  46.         m[sport].second.insert({{-b, sh}, name});
  47.     }
  48.     set<string> ans;
  49.     for(auto x : m) {
  50.         int c = 0;
  51.         for (auto i = x.second.second.begin(); i != x.second.second.end(); i++) {
  52.             ans.insert((*i).second);//cout << (*i).second << endl;
  53.             c++;
  54.             if (c >= x.second.first)
  55.                 break;
  56.         }
  57.     }
  58.     for (auto i = ans.begin(); i != ans.end(); ++i) {
  59.         cout << *i << endl;
  60.     }
  61.  
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement