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:
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 <climits>
using namespace std;
int main(){int h1,m1,s1,h2,m2,s2;int inTime,outTime,minTime = INT_MAX,maxTime = INT_MIN;//最小值初始化为最大、最大值初始化为最小string name,unlocked,locked;int n;cin >> n;while(n--){cin >> name;scanf("%d:%d:%d %d:%d:%d",&h1,&m1,&s1,&h2,&m2,&s2);inTime = h1*3600 + m1*60 + s1;outTime = h2*3600 + m2*60 + s2;if(inTime < minTime){minTime = inTime;unlocked = name;}if(outTime > maxTime){maxTime = outTime;locked = name;}}cout << unlocked << " " << locked;return 0;
}

【PAT】A1006 Sign In and Sign Out (25) (查找)相关推荐

  1. [Java] 1006. Sign In and Sign Out (25)-PAT甲级

    1006. Sign In and Sign Out (25) At the beginning of every day, the first person who signs in the com ...

  2. 【PAT甲】1006 Sign In and Sign Out (25分)循环模拟

    problem 1006 Sign In and Sign Out (25分) At the beginning of every day, the first person who signs in ...

  3. PAT甲级1006 Sign In and Sign Out:[C++题解]字符串处理

    文章目录 题目分析 题目链接 题目分析 读入三个字符串. 需要记录最早开门的人的id和时间,最晚离开的人的id和时间. 本题的简单之处在于 时间的位数都相同,比如 10点和01点.因此这样的时间大小比 ...

  4. 1006. Sign In and Sign Out (25)

    1006. Sign In and Sign Out (25) 问题描述: At the beginning of every day, the first person who signs in t ...

  5. Sign In and Sign Out

    1006. Sign In and Sign Out (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...

  6. PAT甲级1066 Root of AVL Tree (25分):[C++题解]建立平衡树(AVL树)

    文章目录 题目分析 题目链接 题目分析 图片来源:acwing 分析 平衡树(AVL树)是平衡二叉搜索树的简称,当然需要满足二叉搜索树的性质,左子树小于根,根小于等于右子树:然后还要满足平衡树的基本特 ...

  7. [sign in和sign up哪个是注册?哪个是登入?]

    sign in和sign up的意思: 如果是网站的话sign up是注册,sign in是登录的意思,另外,sign out退出

  8. (翻译)‘Sign Up’ 和‘Sign In’按钮让用户混淆的原因

      你能多快看出"Sign Up(PS:注册)"和"Sign In(PS:登录)"的区别?将它们作为按钮名称同时使用,会让用户点错按钮.出现上述问题并不是用户的 ...

  9. 【PAT - 甲级1006】Sign In and Sign Out (25分)(STLmap)

    题干: At the beginning of every day, the first person who signs in the computer room will unlock the d ...

最新文章

  1. Citrix XenDesktop 7.X 视频播放优化
  2. InnoDB Spin rounds per wait在32位机器上可能为负
  3. jzoj5230-队伍统计【状压dp】
  4. mybatis多表查询出来的实体如何映射_mybatis进阶案例之多表查询
  5. 【渝粤教育】电大中专审计原理与实务 (2)作业 题库
  6. vs2008补丁发布
  7. pycharm设置工程运行环境
  8. 卸载联想硬盘保护系统
  9. 智能汽车领域的开源软件供应链安全检测工具分享
  10. 软件测试面试101问(附答案)
  11. PDF文件太大了,如何免费压缩变小?
  12. 关于CClientDC与CPAINTDC,以及GetDC与GetWindowDC。
  13. Windows 窗口发送消息参数详解
  14. 电商优惠券,优惠码的生成
  15. 偏度和峰度存在的意义
  16. 嵌入式linux编译程序,构造嵌入式Linux(一):Kernel编译
  17. JS 实现 图片幻灯片 效果。 兼容 FF IE
  18. AR路由器web界面每IP限速配置方法
  19. 【案例教程】地球科学数据(ERA5、雪深、积雪覆盖、海温、植被指数、土地利用)处理实践
  20. 网易云音乐开发--通过网易云音乐api,游客登录页面验证效果实现

热门文章

  1. Android音视频【十三】OpenSL ES介绍基于OpenSL ES实现音频采集
  2. 年终体检,你会紧张么?
  3. 一文带你深入通读Prometheus ,集群管理最全集锦
  4. ISDN交换机,ATM交换机,ATM/FastGB以太网交换机,工作与交换机之间有什么差别?
  5. [FineReport帆软]使用gif图片背景/设置动态背景
  6. 计算机网络 数据链路层——广播信道 简记
  7. 计网考点 使用广播信道的数据链路层
  8. EBGP vs IBGP
  9. 关于UNIGINE的一些了解
  10. 基于PHP+MySQL医院管理系统的设计与开发