PAT1006 Sign In and Sign Out

请根据记录找出当天开门和关门的人。

 

Sample Input:

3
CS301111 15:30:28 17:00:10
SC3021234 08:00:00 11:25:25
CS301133 21:45:00 21:58:40
Sample Output:
SC3021234 CS301133

 

 

 

 

#include <iostream>
#include <string>
using namespace std;

int main()
{
	int M;
	cin>>M;
	int Entertime = -1;
	int Leavetime = -1;
	string EnterID,LeaveID;
	while (M--)
	{
		string str;
		int t1,t2,t3,t4,t5,t6;
		char c;
		cin>>str>>t1>>c>>t2>>c>>t3>>t4>>c>>t5>>c>>t6;
		int time1 = t1*3600 + t2*60 + t3;
		int time2 = t4*3600 + t5*60 + t6;

		if (time1 < Entertime || Entertime == -1)
		{
			EnterID = str;
			Entertime = time1;
		}

		if (time2 > Leavetime || Leavetime == -1)
		{
			LeaveID = str;
			Leavetime = time2;
		}

	}
	cout<<EnterID<<" "<<LeaveID;
	return 0;
}
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值