PAT 甲級 1006. 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 "cstring"
#include <stdio.h>
#include "iomanip"
#include "vector"
#include "cmath"
#include "stack"
#include "algorithm"
#include <math.h>
#include "map"
#include "queue"
using namespace std;

int main()
{
 
 int n,h,m,s;
 int in=777777777,out=0;
 string name,iname,oname;
 cin>>n;
 while(n--)
 {
     cin>>name;
     scanf("%d:%d:%d",&h,&m,&s);
     int t=s+m*60+h*3600;
     if(in>t)
     {
         iname=name;
         in=t;
     }
     scanf("%d:%d:%d",&h,&m,&s);
     t=s+m*60+h*3600;
     if(out<t)
     {
         oname=name;
         out=t;
     }
 }

 cout<<iname<<" "<<oname;


 return  0;


}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章