美文网首页PAT (Advanced Level) Practice
1006 Sign In and Sign Out (25poi

1006 Sign In and Sign Out (25poi

作者: iphelf | 来源:发表于2020-02-28 00:20 被阅读0次

    两次sort,完事。

    #include<cstdio>
    #include<iostream>
    #include<vector>
    #include<string>
    #include<algorithm>
    using namespace std;
    
    struct P{
        string in,out,id;
    };
    
    bool cmpIn(P &l,P &r){return l.in<r.in;}
    bool cmpOut(P &l,P &r){return l.out<r.out;}
    
    int main(void) {
    //    freopen("in.txt","r",stdin);
        int N;
        cin>>N;
        vector<P> p(N);
        for(int i=0;i<N;i++) cin>>p[i].id>>p[i].in>>p[i].out;
        sort(p.begin(),p.end(),cmpIn);
        cout<<p[0].id<<' ';
        sort(p.begin(),p.end(),cmpOut);
        cout<<p[N-1].id<<endl;
        return 0;
    }
    
    /*
    Sample Input:
    3
    CS301111 15:30:28 17:00:10
    SC3021234 08:00:00 11:25:25
    CS301133 21:45:00 21:58:40
    
    Sample Output:
    SC3021234 CS301133
    */
    
    

    相关文章

      网友评论

        本文标题:1006 Sign In and Sign Out (25poi

        本文链接:https://www.haomeiwen.com/subject/reyqhhtx.html