PAT 甲级 A1006 (2019/02/03)

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 using namespace std;
 5 struct TNode{
 6     char id[20];
 7     int hh, mm, ss;
 8 }temp, in, out;
 9 bool Judge(TNode temp,TNode in){
10     if(temp.hh != in.hh) return temp.hh > in.hh;
11     if(temp.mm != in.mm) return temp.mm > in.mm;
12     return temp.ss > in.ss;    
13 }
14 int main(){
15     int n;
16     scanf("%d",&n);
17     in.hh = 24; in.mm = 60; in.ss = 60;
18     out.hh = 0, out.mm = 0; out.ss = 0;
19     for(int i = 0; i < n; i++){
20         scanf("%s %d:%d:%d",temp.id, &temp.hh, &temp.mm, &temp.ss);
21         if(Judge(temp,in) == false) 
22             in = temp;
23         scanf("%d:%d:%d",&temp.hh, &temp.mm, &temp.ss);
24         if(Judge(temp,out) == true) 
25             out = temp;
26     }
27     printf("%s %s", in.id, out.id);
28     return 0;    
29 } 

猜你喜欢

转载自www.cnblogs.com/zjsaipplp/p/10415775.html
今日推荐