1006 Sign In and Sign Out (25分)

#include<iostream>
#include <cstdio>
#include <string.h>

#include <math.h>

using namespace std;

int time_value(int h,int m,int s)
{
return h*3600+m*60+s;
}
int main()
{
int T;
cin>>T;

char first_in[20];
char last_out[20];
int in_time=24*3600;
int out_time=0;
for(int i=0; i<T; i++)
{
char name[20];
cin>>name;

int hour,minute,second;
scanf("%d:%d:%d",&hour,&minute,&second);
int time = time_value(hour,minute,second);

//cout<<time<<endl;

if(time < in_time)
{
strcpy(first_in,name);
in_time = time;
}
scanf("%d:%d:%d",&hour,&minute,&second);
time = time_value(hour,minute,second);
if(time > out_time)
{
strcpy(last_out,name);
out_time = time;
}
}
cout<<first_in<<" "<<last_out;
}

posted @ 2020-08-19 23:23  houyz  阅读(108)  评论(0)    收藏  举报