Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<map>
- #include<vector>
- #include<sstream>
- #include<set>
- #include<queue>
- #include<algorithm>
- #include <type_traits>
- using namespace std;
- struct Player {
- Player(int score, int penalty, string id) : score(score), penalty(penalty), id(id) {}
- int score;
- int penalty;
- string id;
- };
- bool comp(const Player& p1,const Player& p2) {
- return p1.score > p2.score || (p1.score == p2.score && p1.penalty < p2.penalty);
- }
- using Comp = std::integral_constant<decltype(&comp), &comp>;
- struct Competition {
- Competition() {}
- Competition(int count) : player_places(count) {}
- int player_places;
- set <Player, Comp> players(Comp) ;
- };
- int main()
- {
- int n;
- cin >> n;
- map<string, Competition> m;
- for (int i = 0; i < n; ++i)
- {
- string s;
- cin >> s;
- int tmp = s.find(',');
- m.insert( { s.substr(0, tmp),
- *(new Competition(stoi(s.substr(tmp + 1, s.size()))))});
- }
- int k;
- cin >> k;
- for (int i = 0; i < k; ++i) {
- string s;
- cin >> s;
- int tmp = s.find(',');
- string id = s.substr(0, tmp);
- int tmp2 = s.find(',',tmp + 1) - tmp - 1;
- string comp = s.substr(tmp + 1, tmp2);
- tmp += tmp2 + 1;
- tmp2 = s.find(',', tmp + 1) - tmp - 1;
- int score = stoi(s.substr(tmp + 1, tmp2));
- tmp += tmp2 + 1;
- int penalty = stoi(s.substr(tmp + 1, s.size()));
- cout << id << ' ' << comp << ' ' << score << ' ' << penalty << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement