Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- #include <map>
- using namespace std;
- int main() {
- int count;
- cin >> count;
- vector<pair<string, int>>candidate;
- for (int i = 0; i < count; ++i) {
- string name;
- int age;
- cin >> name >> age;
- candidate.push_back({ name, age });
- }
- sort(candidate.begin(), candidate.end(), [](const pair<string, int>& one, const pair<string, int>&two) {
- return (one.second == two.second) ? one.first > two.first: one.second > two.second; //тернарный оператор
- });
- for (const auto& [name, age] : candidate) {
- std::cout << name << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement