题目很简单不多说了,我只是觉得这题目的输入方式还是很有特点的
1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #include <iostream> 5 using namespace std; 6 7 struct People{ 8 char name[20]; 9 int h1 , h2 , m1 , m2 , s1 , s2; 10 }p[10005]; 11 12 bool cmp1(const People &p1 , const People &p2){ 13 if(p1.h1 == p2.h1 && p2.m1 == p1.m1) return p1.s1 < p2.s1; 14 else if(p1.h1 == p2.h1) return p1.m1 < p2.m1; 15 else return p1.h1 < p2.h1; 16 } 17 18 bool cmp2(const People &p1 , const People &p2){ 19 if(p1.h2 == p2.h2 && p2.m2 == p1.m2) return p1.s2 > p2.s2; 20 else if(p1.h2 == p2.h2) return p1.m2 > p2.m2; 21 else return p1.h2 > p2.h2; 22 } 23 24 int main() 25 { 26 // freopen("a.in" , "r" , stdin); 27 int T , n; 28 scanf("%d" , &T); 29 while(T--){ 30 scanf("%d" , &n); 31 memset(p , 0 , sizeof(p)); 32 for(int i = 1 ; i<=n ; i++){ 33 scanf("%s%d:%d:%d%d:%d:%d" , p[i].name , &p[i].h1 , &p[i].m1 , 34 &p[i].s1 , &p[i].h2 , &p[i].m2 , &p[i].s2); 35 // cout<<p[i].h1<<":"<<p[i].m1<<":"<<p[i].s1<<endl; 36 } 37 sort(p+1 , p+n+1 , cmp1); 38 printf("%s " , p[1].name); 39 sort(p+1 , p+n+1 , cmp2); 40 printf("%s " , p[1].name); 41 } 42 return 0; 43 }