1006. Sign In and Sign Out (25)
来源:互联网 发布:师洋淘宝直播还骂人 编辑:程序博客网 时间:2024/06/07 14:54
At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in's and out's, you are supposed to find the ones who have unlocked and locked the door on that day.
Input Specification:
Each input file contains one test case. Each case contains the records for one day. The case starts with a positive integer M, which is the total number of records, followed by M lines, each in the format:
ID_number Sign_in_time Sign_out_time
where times are given in the format HH:MM:SS, and ID number is a string with no more than 15 characters.
Output Specification:
For each test case, output in one line the ID numbers of the persons who have unlocked and locked the door on that day. The two ID numbers must be separated by one space.
Note: It is guaranteed that the records are consistent. That is, the sign in time must be earlier than the sign out time for each person, and there are no two persons sign in or out at the same moment.
Sample Input:3CS301111 15:30:28 17:00:10SC3021234 08:00:00 11:25:25CS301133 21:45:00 21:58:40Sample Output:
SC3021234 CS301133
#include<iostream>#include<cstring>#include<cstdio>#include<queue>#include<stack>#include<algorithm>#include<cmath>using namespace std;typedef struct node{char name[200];int h,m,s;int h1,m1,s1;}node; bool cmp(node n1,node n2){if(n1.h==n2.h){if(n1.s==n2.s){return n1.s<n2.s;}else{return n1.m<n2.m;}}elsereturn n1.h<n2.h;}bool cmp1(node n1,node n2){if(n1.h1==n2.h1){if(n1.s1==n2.s1){return n1.s1>n2.s1;}else{return n1.m1>n2.m1;}}elsereturn n1.h1>n2.h1;}int main(){node n1[1000];int m;cin>>m;for(int i=0;i<m;i++){cin>>n1[i].name;scanf("%d:%d:%d %d:%d:%d",&n1[i].h,&n1[i].m,&n1[i].s,&n1[i].h1,&n1[i].m1,&n1[i].s1);}sort(n1,n1+m,cmp);cout<<n1[0].name<<" ";sort(n1,n1+m,cmp1);cout<<n1[0].name;return 0;}
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 通过StackTraceElement获取方法调用者的具体信息
- 滴滴工程师HBasecon2017参会感受
- 集群与分布式
- hdu-1009-贪心-FatMouse' Trade
- C++模板的全特化和偏特化
- 1006. Sign In and Sign Out (25)
- HDU 2369 尺取法
- bzoj1880: [Sdoi2009]Elaxia的路线
- 只谈 Unity中 yield return/ StartCoroutine 的使用
- 1007. Maximum Subsequence Sum (25)
- MySQL(四)
- jQuery获取建立唯一ID
- MFC 关于SendMessage 消息参数 传送字符串,结构体
- [7.8] 纪中C组