12536 - People nowadays
raw download clone
CPP
views 15
,
size 1109 b
#include <iostream>
#include <utility>
#include <string>
#include <map>
#include <set>

using namespace std;

int main()
{
    set<pair<int, string>> Set;
    int n;
    cin>>n;
    while(n--){
        string temp;
        cin>>temp;
        if(temp == "born"){
            string name;
            int age;
            cin>>name>>age;
            Set.insert(make_pair(age, name));
        }
        else if(temp == "find"){
            string name;
            int age;
            cin>>name>>age;
            if(Set.find(make_pair(age, name)) == Set.end()){
                cout<<"NO\n";
            }
            else{
                cout<<"YES\n";
            }
        }
        else if(temp == "kill"){
            string name;
            int age;
            cin>>name>>age;
            if(Set.find(make_pair(age, name)) != Set.end()){
                Set.erase(Set.find(make_pair(age, name)));
            }
        }
        else if(temp == "young"){
            cout<<Set.begin()->second<<" "<<Set.begin()->first<<"\n";
        }
    }
    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.