2 solutions

  • 0
    @ 2022-3-29 15:47:37

    暴力

    #include <bits/stdc++.h>
    using namespace std;
    
    struct Node{
        int x;
        int y;
    };
    vector<Node> v;
    
    int main(){
        int n;
        cin>>n;
        while(n--){
            string op;
            cin>>op;
            if(op == "ADD"){
                Node usr;
                cin>>usr.x>>usr.y;
                v.push_back(usr);
            }
            else{
                int x1,y1,size = 0;
                cin>>x1>>y1;
                for(vector<Node>::iterator i = v.begin() ; i != v.end() ; i++){
                    if((*i).x == x1){
                        size++;
                    }
                    if(size == y1){
                        cout<<(*i).y<<endl;
                        break;
                    }
                }
                if(size < y1){
                    cout<<"-1"<<endl;
                }
            }
        }
        return 0;
    }
    

    Information

    ID
    825
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    2
    Tags
    # Submissions
    41
    Accepted
    27
    Uploaded By