两次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
*/
网友评论