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
 
题目意思:第一个进机房的人开锁,最后一个出机房的人上锁关门,给出每个人的ID和进机房出机房的时间,找出开锁和上锁人的ID。
解题思路:由于时间采用的是24h制,所以在同一的格式下,将时间全都转换为秒数是最方便的,之后便利比较,找出最大和最小时间即可。
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
using namespace std;
int main()
{
int k,h,m,s;
int i,in_time,out_time;
int maxs=,mins=0x7fffffff;
string str,unlock,lock;
cin>>k;
for(i=; i<k; i++)
{
cin>>str;
scanf("%d:%d:%d",&h,&m,&s);
in_time=h*+m*+s;
scanf("%d:%d:%d",&h,&m,&s);
out_time=h*+m*+s;
if(in_time<mins)
{
mins=in_time;
unlock=str;
}
if(out_time>maxs)
{
maxs=out_time;
lock=str;
}
}
cout<<unlock<<" "<<lock;
return ;
}

PAT 1006 Sign In and Sign Out 查找元素的更多相关文章

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

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

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

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

  6. PAT Sign In and Sign Out[非常简单]

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

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

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

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

  10. PAT/查找元素习题集

    B1004. 成绩排名 (20) Description: 读入n名学生的姓名.学号.成绩,分别输出成绩最高和成绩最低学生的姓名和学号. Input: 每个测试输入包含1个测试用例,格式为: 第1行: ...

随机推荐

  1. django基础之day09,Forms组件在程序中做了哪些事? 校验数据、渲染标签、展示信息

    ******************************* Forms组件 *************************************************** Forms组件在 ...

  2. Python基础知识第八篇(集合)

    #集合是无序的#集合是不同元素组成的#集合是不可变的,列如:列表,字典,元组#创建空集合 s=set() # s={1,2,3,4,2} # print(s) #集合添加>>>> ...

  3. CQRS+ES项目解析-Equinox

    今天我们来分析另一个开源的CQRS+ES项目:Equinox.该项目可以在github上下载并直接本地运行,项目地址:https://github.com/EduardoPires/EquinoxPr ...

  4. C# yield关键字

    关于yield关键字,网上有很多文章介绍了,但是看了之后,虽然明白了"哦,原来是这么回事",但是在日常开发中并没有真正的用起来,所以,写此一篇,介绍一下在真正的项目中怎么使用这个关 ...

  5. 创建基于ASP.NET core 3.1 的RazorPagesMovie项目(二)-应用模型类配合基架生成工具生成Razor页面

    本节中,将学习添加用于管理跨平台的SQLLite数据库中的电影的类Movie.从ASP.NET core 模板创建的应用使用SQLLite数据库. 应用模型类(Movie)配合Entity Frame ...

  6. distcc 的使用

    在项目的开发过程中,经常出现多个开发人员集中在某个 linux 内网开发机上统一开发的情况,随着开发人员越来越多.项目编译得越来越频繁,开发机的压力越来越大,所以考虑用代码交叉编译的方式来缓解开发机的 ...

  7. Docke部署nginx并配置nginx

    一.在docker中下载nginx镜像 docker pull nginx 二.在宿主机中创建挂在目录 mkdir -p /data/nginx/{conf,conf.d,html,log} 三.在挂 ...

  8. docker快速安装rabbitmq

    1.进入docker hub镜像仓库地址:https://hub.docker.com/ 2.搜索rabbitMq,进入官方的镜像,可以看到以下几种类型的镜像:我们选择带有“mangement”的版本 ...

  9. 备份下ESP8266的AT指令集手册和用例手册中文版,准备为V7做几个ESP8266的例子

    指令集手册:https://files.cnblogs.com/files/armfly/4a-esp8266_at_instruction_set_cn.rar 用例手册: https://file ...

  10. react-组件间的传值

    父组件向子组件传值 父组件通过属性进行传递,子组件通过props获取 //父组件 class CommentList extends Component{ render(){ return( < ...