题目:
根据上下班打卡的记录,找到在那一天第一个开门和最后一个锁门的人。
输入格式:
每个输入文件包含一个测试用例。每个病例都有一天的记录。案例以一个正整数M开始,它是记录的总数,后跟M行,每行的格式如下:
ID 登入时间 登出时间
其中时间以HH:MM:SS
的格式给出,ID_number
是一个不超过15个字符的字符串。
输出格式:
对于每个测试用例,在一行中输出当天开锁和锁门的人员的ID号。两个身份证号码必须用一个空格隔开。
注:保证记录一致。也就是说,每个人的登录时间必须早于注销时间,并且没有两个人同时登录或注销。
输入样例:
3
CS301111 15:30:28 17:00:10
SC3021234 08:00:00 11:25:25
CS301133 21:45:00 21:58:40
输出样例:
SC3021234 CS301133
AC代码:
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
string earliest,lastest,temp;
int early=24*60*60,last=0;
int time=0,h,m,s;
for(int i=0;i<n;i++){
cin>>temp;
scanf("%d:%d:%d",&h,&m,&s);
time=h*60*60+m*60+s;
if(time<early){
earliest=temp;
early=time;
}
scanf("%d:%d:%d",&h,&m,&s);
time=h*60*60+m*60+s;
if(time>last){
lastest=temp;
last=time;
}
}
cout<<earliest<<" "<<lastest<<endl;
return 0;
}