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. Leetcode: Matchsticks to Square && Grammar: reverse an primative array

    Remember the story of Little Match Girl? By now, you know exactly what matchsticks the little match ...

  2. 《量化投资:以MATLAB为工具》连载(1)基础篇-N分钟学会MATLAB(上)

    http://blog.sina.com.cn/s/blog_4cf8aad30102uylf.html <量化投资:以MATLAB为工具>连载(1)基础篇-N分钟学会MATLAB(上) ...

  3. 常用的Linux命令

    1.如何创建一个目录?mkdir DirectoryName 2.如何进入服务器根目录?ls / 3.如何查看日历?cal 4.如何修改密码?passwd 5.如何查看当前用户信息?whoami 6. ...

  4. Coins

    Description Whuacmers use coins.They have coins of value A1,A2,A3...An Silverland dollar. One day Hi ...

  5. __PUBLIC__ 路径更改

    config.php 'TMPL_PARSE_STRING' => array( '__PUBLIC__' => __ROOT__ . '/' . APP_NAME . '/Tpl/Pub ...

  6. Mvc4中使用Spring.Net实现IOC和DI

    一个Hello类,一个IHello接口 1.引用dll 2.修改Global文件 (SpringMvcApplication) 3.控制器添加属性 4.WebConfig配置 5.Spring.xml ...

  7. 二十一、Java基础--------IO流之综合案例分析

    前三篇文章详细介绍了IO流体系所涉及的重点内容,为了帮助理解与学习,本片博客主要是分析一个与IO操作相关的题目. 例1:在我们观看视频时经常要关注的就是视频的时间长度,在学习了IO操作之后,就可以自己 ...

  8. python学习笔记之基础一(第一天)

    1. python字符介绍 在C语言中没有字符串,只有字符 在python中的字符串hello,在C语言中是以字符数组在内存存放['h','e','l','l','o'],如果对字符串修改,则是在内存 ...

  9. ArcGIS10.1 发布气温插值GP服务

    首先通过ModelBuilder 工具 构建模型 然后通过模块右键 设置输入参数 或者直接将一个模块设为输入参数 在输出模块的右键属性上 可以设置lyr文件用于渲染 设置数据添加到显示用于不是发布的时 ...

  10. 安装VS2012以后打开office 2007 的任何程序都跳出VS2012配置界面的解决方案

    前两天闲来无事,下载了vs2012,打算学点mvc4的东西,装好以后,问题来了,打开word文档,直接弹出个windows正在配置vs2012的界面,等就等一下吧,结束以后还能正常看,结果谁知道,每次 ...