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

还是一道很简单的题,但是值得纪念的是第一次提交就全对了!
用的是map然后重载运算符分别求最大和最小。
bool operator <(const data t1,const data t2){return ...}
#include <iostream>
#include <map>
#include <string>
using namespace std; typedef struct data{
int h,m,s;
}data; bool operator<(const data &t1,const data &t2){ return (t1.h<t2.h) || (t1.h==t2.h&&t1.m<t2.m) || (t1.h==t2.h&&t1.m==t2.m&&t1.s<t2.s); } map<data,string> in;
map<data,string> out; data intime[];
data outtime[]; int main()
{
int n;
cin>>n;
int i=;
while(n--){
string Itime,Otime,ID;
cin>>ID>>Itime>>Otime;
data I,O;
I.h=(Itime[]-)*+(Itime[]-);
I.m=(Itime[]-)*+(Itime[]-);
I.s=(Itime[]-)*+(Itime[]-);
O.h=(Otime[]-)*+(Otime[]-);
O.m=(Otime[]-)*+(Otime[]-);
O.s=(Otime[]-)*+(Otime[]-);
in[I]=ID;
out[O]=ID;
intime[i]=I;
outtime[i]=O;
i++;
}
data min;
min.h=,min.m=,min.s=;
for(int j=;j<i;j++){
if(intime[j]<min){
min.h=intime[j].h;
min.m=intime[j].m;
min.s=intime[j].s;
}
}
cout<<in[min];
data max;
max.h=,max.m=,max.s=;
for(int j=;j<i;j++){
if(max<outtime[j]){
max.h=outtime[j].h;
max.m=outtime[j].m;
max.s=outtime[j].s;
}
}
cout<<" "<<out[max];
return ;
}

1006. Sign In and Sign Out (25)的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. pat1006. Sign In and Sign Out (25)

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

  8. PTA (Advanced Level) 1006 Sign In and Sign Out

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

  9. 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 ...

  10. PAT1006:Sign In and Sign Out

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

随机推荐

  1. C语言数据类型取值范围

    一.获取数据类型在系统中的位数 在不同的系统中,数据类型的字节数(bytes)不同,位数(bits)也有所不同,那么对应的取值范围也就有了很大的不同,那我们怎么知道你当前的系统中C语言的某个数据类型的 ...

  2. jQuery .attr("checked")得undefined 问题解决

    出现此错误是因为JQuery版本升级的问题.所以此处应该使用.prop(); 那么,什么时候使用attr(),什么时候使用prop()?1.添加属性名称该属性就会生效应该使用prop();2.是有tr ...

  3. chattr的常用参数详解

    chattr的常用参数详解 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 在实际生产环境中,有的运维工程师不得不和开发和测试打交道,在我们公司最常见的就是部署接口.每天每个人部署的 ...

  4. git/github学习笔记

    郑重提示,本文来自这里,如果喜欢,请关注原作者. 1. git 版本控制系统 相比CVS\SVN优势: - 支持离线开发,离线Repository- 强大的分支功能,适合多个独立开发者协作- 速度块 ...

  5. 【004: gcc 和 clang 的简单比较】

  6. 桌面显卡天梯图和桌面cpu天梯图

    桌面cpu天梯图: 桌面显卡天梯图:

  7. [liusy.api-SMJ]-创建工程范例 MAVEN archetype 学习阶段(一)

    由于这个架构需要好多不同能力的工程,为了创建方便减少冗余,创建工程范例尤为重要 学习阶段: 参考资料 http://maven.apache.org/archetype/maven-archetype ...

  8. WebApi身份认证解决方案:Basic基础认证

    前言:最近,讨论到数据库安全的问题,于是就引出了WebApi服务没有加任何验证的问题.也就是说,任何人只要知道了接口的url,都能够模拟http请求去访问我们的服务接口,从而去增删改查数据库,这后果想 ...

  9. 谈谈我印象中的JVM不足之处

    研究JVM也有一段时间了,其间也发现了它的很多不足之处,在此一一道来,由于本人对JVM的理解有限,如有错误的地方,还请大家指正:本文不介绍名词性术语和概念性知识,如有不了解的地方可Search Goo ...

  10. Linux_用户级_常用命令(4):cp

    Linux_用户级_常用命令之cp 开篇语:懒是人类进步的源动力 本文原创,专为光荣之路公众号所有,欢迎转发,但转发请务必写出处! Linux常用命令第二集包含命令:cp 格式 cp  [-optio ...