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

题目大意:给出n个人的id、sign in时间、sign out时间,求最早进来的人和最早出去的人的ID~

分析:将时间都转换为总秒数,最早和最迟的时间保存在变量minn和maxn中,并同时保存当前最早和最迟的人的ID,最后输出~

#include <iostream>
#include <climits>
using namespace std;
int main() {int n, minn = INT_MAX, maxn = INT_MIN;scanf("%d", &n);string unlocked, locked;for(int i = 0; i < n; i++) {string t;cin >> t;int h1, m1, s1, h2, m2, s2;scanf("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);int tempIn = h1 * 3600 + m1 * 60 + s1;int tempOut = h2 * 3600 + m2 * 60 + s2;if (tempIn < minn) {minn = tempIn;unlocked = t;}if (tempOut > maxn) {maxn = tempOut;locked = t;}}cout << unlocked << " " << locked;return 0;
}

1006. Sign In and Sign Out (25)-PAT甲级真题相关推荐

  1. 1020. Tree Traversals (25) PAT甲级真题

    之前我看了这道题,实在是看不懂网上的解题答案,他们的具体思路基本上就是通过后续遍历和中序遍历,直接推出层次遍历. 我苦思冥想了半天,是在没看懂这种思路,于是想了一个笨点的但是也比较好理解的思路,通过后 ...

  2. 1078. Hashing (25)-PAT甲级真题

    1078. Hashing (25) The task of this problem is simple: insert a sequence of distinct positive intege ...

  3. 1040. Longest Symmetric String (25)-PAT甲级真题

    Given a string, you are supposed to output the length of the longest symmetric sub-string. For examp ...

  4. 1121. Damn Single (25)-PAT甲级真题

    "Damn Single (单身狗)" is the Chinese nickname for someone who is being single. You are suppo ...

  5. 1090. Highest Price in Supply Chain (25)-PAT甲级真题

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

  6. 1106. Lowest Price in Supply Chain (25)-PAT甲级真题(dfs,bfs,树的遍历)

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

  7. 1114. Family Property (25)-PAT甲级真题(并查集)

    This time, you are supposed to help us collect the data for family-owned property. Given each person ...

  8. 1102. Invert a Binary Tree (25)-PAT甲级真题

    The following is from Max Howell @twitter: Google: 90% of our engineers use the software you wrote ( ...

  9. 1032. Sharing (25)-PAT甲级真题

    To store English words, one method is to use linked lists and store a word letter by letter. To save ...

最新文章

  1. Ubuntu下ssh免password登录安装
  2. 【Android 逆向】应用数据目录 ( Android 应用数据目录 /data/data/package.name | 存放 SharedPreference 的 shared_pref 目录 )
  3. mysql空表_MySQL中两种快速创建空表的方式
  4. 【JFreeChart】JFreeChart—输出柱形图
  5. swift和oc区别----属性部分(参考官方swift2.1文档)
  6. C++局部变量和全局变量的初始化
  7. 快排的c++实现(两种实现方式)
  8. 统计学习方法读书笔记7-K近邻习题
  9. git 中 HEAD 概念
  10. #Paper Reading# Implicit Neural Representations with Periodic Activation Functions
  11. ON_NOTIFY处理消息
  12. mac下启动/停止/重启mysql服务
  13. BTG遭遇51%攻击,幕后黑手竟是他!
  14. 学计算机专业的人,如何让别人明白“学习或从事计算机专业的人不一定会修电脑”,只是会秃头!...
  15. 【LayIM】开发者文档
  16. python dataframe增加一行_python - 在pandas.DataFrame中添加一行
  17. 斗米App首次分享:召回沉默用户的技巧和思考(附PDF)
  18. linux下配置jdk11以及生成jre,jdk9以上自动生成jre解决
  19. 都在讲降本增效,优化师如何借力“卷起来”?
  20. Alientek I.MX6UL Linux-第八章 汇编LED灯实验

热门文章

  1. Ubuntu ibus 输入法之Skype不能输入中文
  2. 《IT项目管理那些事儿》——国内第一本项目管理的实践书籍
  3. 《结对-结对编程项目作业名称-结对项目总结》
  4. php 上传大文件主要涉及配置upload_max_filesize和post_max_size两个选项
  5. 2017-10-7Linux基础知识(5)基本命令
  6. DELETE_FAILED_INTERNAL_ERROR Error while Installing APK
  7. 通过反射获取私有方法
  8. 【Android】【录音】Android录音--AudioRecord、MediaRecorder
  9. KindleDrip:从邮件地址到信用卡盗刷的严重漏洞,值$1.8万奖金
  10. BCS冬奥主题活动日:奥运网络安全成全球关注焦点