Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- #include<string>
- #include<map>
- #include<unordered_map>
- #include<algorithm>
- using namespace std;
- struct applicant {
- string name, surname;
- int birth_day, birth_month, birth_year, score;
- vector<string> universities;
- void read() {
- cin >> name >> surname >> birth_day >> birth_month >> birth_year >> score;
- int k;
- cin >> k;
- universities.resize(k);
- for (int i = 0; i < k; i++)
- cin >> universities[i];
- return;
- }
- tuple<int, int, int, int, string, string> to_tuple() const {
- return make_tuple(-score, birth_year, birth_month, birth_day, surname, name);
- }
- bool operator < (const applicant& other) const {
- return to_tuple() < other.to_tuple();
- }
- };
- bool cmp_students(const pair<string, string> &a, const pair<string, string> &b) {
- return make_tuple(a.second, a.first) < make_tuple(b.second, b.first);
- }
- int main() {
- unordered_map<string, int> quotas;
- int universities_number;
- cin >> universities_number;
- for (int i = 0; i < universities_number; i++) {
- string name;
- cin >> name;
- cin >> quotas[name];
- }
- int applicants_number;
- cin >> applicants_number;
- vector<applicant> applicants(applicants_number);
- for (int i = 0; i < applicants_number; i++) {
- applicants[i].read();
- }
- map<string, vector<pair<string, string>>> admission;
- for (const auto& a : applicants) {
- for (const auto& university : a.universities)
- if (admission[university].size() < quotas[university]) {
- admission[university].emplace_back(a.name, a.surname);
- break;
- }
- }
- for (auto& [university, students] : admission) {
- cout << university;
- sort(students.begin(), students.end(), cmp_students);
- for (const auto& student : students)
- cout << '\t' << student.first << ' ' << student.second;
- cout << '\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement