1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4 const int maxn = 110;
5 bool compare(int a[],int b[]){//a小于b返回真,否则返回假
6 if(a[0]!=b[0]){
7 return a[0]<b[0];
8 }
9 if(a[1]!=b[1]){
10 return a[1]<b[1];
11 }
12 return a[2]<b[2];
13 }
14 void copy_int(int a[],int b[]){
15 for (int i = 0; i < 3; ++i) {
16 a[i]=b[i];
17 }
18 }
19 int main() {
20 //std::cout << "Hello, World!" << std::endl;
21 int m;
22 char early[20],late[20],tmp[20];
23 int t1[3],t2[3],e[3]={23,59,59},l[3]={0,0,0};
24 scanf("%d",&m);
25 for (int i = 0; i < m; ++i) {
26 scanf("%s %d:%d:%d %d:%d:%d",tmp,&t1[0],&t1[1],&t1[2],&t2[0],&t2[1],&t2[2]);
27 if(compare(t1,e)){//判断最早,e是最大,做右参数
28 strcpy(early,tmp);
29 copy_int(e,t1);
30 }
31 if(compare(l,t2)){//找最晚时间,l最小,做左参数
32 strcpy(late,tmp);
33 copy_int(l,t2);
34 }
35 }
36 printf("%s %s\n",early,late);
37 return 0;
38 }