PAT (Advanced Level) Practise 1006 Sign In and Sign Out
来源:互联网 发布:武汉启瑞药业 知乎 编辑:程序博客网 时间:2024/06/11 02:29
1006. Sign In and Sign Out (25)
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 <cstdio>#include <cmath>#include <cstring>#include <algorithm>#include <stack>#include <queue>#include <vector>#include <map>using namespace std;const int INF=0x3f3f3f3f;int main(){ int n; char s[1005][25]; int mi,ma,h1,h2,m1,m2,s1,s2; while(~scanf("%d",&n)) { scanf("%s %d:%d:%d %d:%d:%d",s[0],&h1,&m1,&s1,&h2,&m2,&s2); ma=3600*h2+60*m2+s2; mi=3600*h1+60*m1+s1; int k1=0,k2=0; for(int i=1;i<=n-1;i++) { scanf("%s %d:%d:%d %d:%d:%d",s[i],&h1,&m1,&s1,&h2,&m2,&s2); int tmp; tmp=3600*h2+60*m2+s2; if(ma<tmp) {ma=tmp,k1=i;} tmp=3600*h1+60*m1+s1; if(tmp<mi) {mi=tmp,k2=i;} } cout<<s[k2]<<" "<<s[k1]<<endl; } return 0;}
- PAT (Advanced Level) Practise 1006 Sign In and Sign Out
- PAT (Advanced Level) Practise 1006Sign In and Sign Out (25)
- Pat(Advanced Level)Practice--1006(Sign In and Sign Out)
- PAT Advanced Level 1006:Sign In and Sign Out
- PAT(Advanced Level) 1006 - Sign In and Sign Out(水题)
- 1006. Sign In and Sign Out (25)——PAT (Advanced Level) Practise
- PAT (Advanced Level) Practise 1006. Sign In and Sign Out (25)
- PAT (Advanced Level) Practise 1006. Sign In and Sign Out (25)
- PAT (Advanced Level) Practise 1006. Sign In and Sign Out (25)
- 【PAT Advanced Level】1006. Sign In and Sign Out (25)
- PAT(Advanced level) 1006. Sign In and Sign Out
- 【PAT (Advanced Level)】1006. Sign In and Sign Out (25)
- 浙大 PAT Advanced level 1006. Sign In and Sign Out
- 【PAT】【Advanced Level】1006. Sign In and Sign Out (25)
- PAT-PAT (Advanced Level) Practise 1006. Sign In and Sign Out (25) (简单题)【一星级】
- pat 1006 Sign In and Sign Out
- PAT 1006 Sign In and Sign Out
- PAT 1006 Sign In and Sign Out
- 蓝桥杯
- 119. Pascal's Triangle II
- 算法总结系列之五: 基数排序(Radix Sort)
- chsh: PAM: Authentication failure
- PTA 5-10 说反话-加强版 【】
- PAT (Advanced Level) Practise 1006 Sign In and Sign Out
- Java SpringMVC文件上传工具类
- lenovo g500 更换ssd
- [欧拉回路 KM] AOJ 2724 Laser Cutter
- acm练习-day1_2
- Android如何在app中通过一个按钮直接跳转到的系统的权限设置页面
- Error: java.lang.RuntimeException: Some file crunching failed, see logs for details
- Oracle PLSQL Exception异常分类、异常抛出、异常处理、异常传播
- maven常见问题归纳