Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define LINT long long int
- #define ULINT unsigned long long int
- #define INF 99999999999
- using namespace std;
- template<typename tmp>
- void input(vector<tmp>& vc) {
- for (tmp& x : vc)
- cin >> x;
- }
- template<typename tmp>
- void output(vector<tmp>& vc, string endll = " ", string endd = "\n") {
- for (tmp& x : vc)
- cout << x << endll;
- cout << endd;
- }
- int main(){
- int n;
- cin >> n;
- map<string, pair<int, set<pair<pair<int, int>, string> > > > m;
- for (int i = 0; i < n; ++i) {
- string t;
- cin >> t;
- int tmp = t.find(',');
- m.insert({t.substr(0, tmp),{stoi(t.substr(tmp + 1, t.size())), set<pair<pair<int, int>, string> >()}});
- }
- int a;
- cin >> a;
- for (int i = 0; i < a; ++i) {
- string s;
- cin >> s;
- int tmp = s.find(','), tmp2;
- string name, sport;
- int sh, b;
- name = s.substr(0, tmp);
- tmp2 = tmp + 1;
- tmp = s.find(',', tmp2);
- sport = s.substr(tmp2, tmp - tmp2);
- tmp2 = tmp + 1;
- tmp = s.find(',', tmp2);
- b = stoi(s.substr(tmp2, tmp - tmp2));
- sh = stoi(s.substr(tmp + 1, s.size() - tmp));
- m[sport].second.insert({{-b, sh}, name});
- }
- set<string> ans;
- for(auto x : m) {
- int c = 0;
- for (auto i = x.second.second.begin(); i != x.second.second.end(); i++) {
- ans.insert((*i).second);//cout << (*i).second << endl;
- c++;
- if (c >= x.second.first)
- break;
- }
- }
- for (auto i = ans.begin(); i != ans.end(); ++i) {
- cout << *i << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement