类型:sort函数排序
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn=10010;
struct Node{
string id;
int in,out;
}node[maxn];
bool cmp1(Node a,Node b){
return a.in<b.in;
}
bool cmp2(Node a,Node b){
return a.out>b.out;
}
int main(){
int n;
scanf("%d",&n);
int sum1,sum2,s1,m1,t1,s2,m2,t2;
string id;
for(int i=0;i<n;i++){
cin>>id;
scanf("%d:%d:%d %d:%d:%d", &s1, &m1, &t1, &s2, &m2, &t2);
node[i].id=id;
node[i].in=s1*3600+m1*60+t1;
node[i].out=s2*3600+m2*60+t2;
}
sort(node,node+n,cmp1);
cout<<node[0].id<<" ";
sort(node,node+n,cmp2);
cout<<node[0].id;
return 0;
}
/*
3
CS301111 15:30:28 17:00:10
SC3021234 08:00:00 11:25:25
CS301133 21:45:00 21:58:40
SC3021234 CS301133*/