PAT 1006. Sign In and Sign Out

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <functional>
#include <string>
#include <queue>

using namespace std;

int main()
{
	int N;
	scanf("%d",&N);
	string nameIn,nameOut;
	int timeIn = 1<<30,timeOut = -1;
	for(int i=0;i<N;i++)
	{
		string name;
		cin>>name;
		int a,b,c,time;
		scanf("%d:%d:%d",&a,&b,&c);
		time = a*60*60 + b*60 + c;
		if(time<timeIn)
		{
			timeIn = time;
			nameIn = name;
		}
		scanf("%d:%d:%d",&a,&b,&c);
		time = a*60*60 + b*60 + c;
		if(time>timeOut)
		{
			timeOut = time;
			nameOut = name;
		}
	}
	cout<< nameIn<<" "<<nameOut<<endl;
	return 0;
}

좋은 웹페이지 즐겨찾기