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



题目大意:在一堆开门关门的员工中,分别找到最早开门和最晚关门的员工号.

分析:利用c++string类型用字典序进行比较的特性直接比较开门时间和关门时间,temp_unlock和temp_lock分别是比较开门时间和关门时间的临时变量,first_unlock和last_lock分别用来记录最早开门和最晚开门的员工号。

#include <iostream>
using namespace std;
int main() {
string first_unlock,final_lock;
int m;
scanf("%d",&m);
string id_number,unlock,lock;
string temp_unlock="9",temp_lock="0";
for(int i=0;i<m;i++)
{
cin>>id_number>>unlock>>lock;
if(unlock<temp_unlock){
temp_unlock=unlock;
first_unlock=id_number;
}
if(lock>temp_lock){
temp_lock=lock;
final_lock=id_number;
}
}
cout<<first_unlock<<" "<<final_lock<<endl;
return 0;
}

1006.Sign in and Sign out(25)—PAT 甲级的更多相关文章

  1. Count PAT's (25) PAT甲级真题

    题目分析: 由于本题字符串长度有10^5所以直接暴力是不可取的,猜测最后的算法应该是先预处理一下再走一层循环就能得到答案,所以本题的关键就在于这个预处理的过程,由于本题字符串匹配的内容的固定的PAT, ...

  2. PAT甲级题解(慢慢刷中)

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  3. 【转载】【PAT】PAT甲级题型分类整理

    最短路径 Emergency (25)-PAT甲级真题(Dijkstra算法) Public Bike Management (30)-PAT甲级真题(Dijkstra + DFS) Travel P ...

  4. PAT (Advanced Level) Practice 1006 Sign In and Sign Out (25 分) 凌宸1642

    PAT (Advanced Level) Practice 1006 Sign In and Sign Out (25 分) 凌宸1642 题目描述: At the beginning of ever ...

  5. PAT 甲级 1006 Sign In and Sign Out (25)(25 分)

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

  6. PAT甲 1006. Sign In and Sign Out (25) 2016-09-09 22:55 43人阅读 评论(0) 收藏

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

  7. pat 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 the com ...

  8. 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 the co ...

  9. 1006 Sign In and Sign Out (25)(25 分)思路:普通的时间比较题。。。

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

  10. PAT甲级——1006 Sign In and Sign Out

    PATA1006 Sign In and Sign Out At the beginning of every day, the first person who signs in the compu ...

随机推荐

  1. (WPF) Textbox 每次输入触发事件处理

    1.  Code behind. protected void TextBox1_TextChanged(object sender, EventArgs e) { Label1.Text = Ser ...

  2. IOS CALayer的属性和使用

    一.CALayer的常用属性 1.@propertyCGPoint position; 图层中心点的位置,类似与UIView的center:用来设置CALayer在父层中的位置:以父层的左上角为原点( ...

  3. AndroidStudio中logcat不输出信息

    2017年11月27日,记住这个日子.今天第一次感觉到被批评了,由于自己技术知识储备不足导致今天的外出工作等于浪费时间.正式因为这个logcat不输出信息的问题,前几回不输出信息了我就从新启动了开发工 ...

  4. AspNetCore发布到Centos7

    1.Centos安装netcore2 sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc sudo sh -c 'e ...

  5. Android SDK和ADT无法更新的解决办法

    重要的东西要标红: 经过另外一台电脑测试,按照第二步设置好hosts后,可以一并解决 SDK 和 ADT的更新,无需单独设置SDK Manager. 这里还是写出如何设置SDK Manager以作记录 ...

  6. 关于用GetManifestResourceNames读不出资源文件的解决

    在写程序时,需要读出所有资源的图片文件,程序工作正常, Assembly asm = Assembly.GetExecutingAssembly();string[] resourceNames = ...

  7. 【转】】Vue项目部署tomcat,刷新报错404解决办法

    转自[https://blog.csdn.net/g631521612/article/details/82835518] 解决方式: - 在tocmat的webapps下的项目中创建WEB-INF文 ...

  8. centos yum升级php

    centos yum升级php5.3.3到最5.6.3 不要轻易升级,否则后果很严重! 注意事项: 1 升级后之前的php扩展不会丢失 自动会安装对应最新php的扩展2 升级后需重启下apache 才 ...

  9. Exchange2016 & Skype for business集成之二 OWA集成IM

    Microsoft Outlook Web App 和IM集成部署或升级Exchange server 2016与Skype for business 2015后使用原来2013版本方法集成OWA网页 ...

  10. 企业办公领域: Windows + Office的组合在未来能抵挡住 Google Apps的冲击么

    从个人角度讲,我基本上不怎么喜欢微软的产品,即便是其无处不见的Windows. Windows 8用了几个月的后,实在无法忍受其某些SB的设计,还是换回Win7.另外自从用上了MacBook 以后, ...