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 分页库,完善分页功能

    作者:HelloGitHub-追梦人物 文中所涉及的示例代码,已同步更新到 HelloGitHub-Team 仓库 在 通过 Django Pagination 实现简单分页 中,我们实现了一个简单的 ...

  2. python基础实战之猜年龄游戏

    目录 一.Python基础实战之猜年龄游戏 给定年龄,用户可以猜三次年龄 年龄猜对,让用户选择两次奖励 用户选择两次奖励后可以退出 age = 18 # 答案 count = 0 # 游戏次数控制 p ...

  3. java8-从Lamda到方法引用和构造引用

    一方法引用概述 经过前面2章Lamda原理引入和Lamda解析,基本就会熟练使用Lamda表达式,这次我们更深入点.来了解一下方法引用. 方法引用是特定Lamda表达式的一种简写,其思路就是能替换La ...

  4. 使用ASP.NET Core 3.x 构建 RESTful API - 3.4 内容协商

    现在,当谈论起 RESTful Web API 的时候,人们总会想到 JSON.但是实际上,JSON 和 RESTful API 没有半毛钱关系,只不过 JSON 恰好是RESTful API 结果的 ...

  5. [UIApplication sharedApplication].keyWindow和[[UIApplication sharedApplication].delegate window]区别

    参考链接:https://www.cnblogs.com/henusyj-1314/p/11643189.html 结论1.在获取到window时最好使用[[UIApplication sharedA ...

  6. Scrcpy用电脑控制Android手机(支持Windows/macOS/Linux)

    一.scrcpy简介 注意:拼写是scrcpy,非Python爬虫框架Scrapy. scrcpy可以通过adb调试的方式来将手机屏幕投到电脑上,并可以通过电脑控制您的Android设备.它可以通过U ...

  7. Navicat Keygen - 注册机是怎么工作的?

    Navicat Keygen - 注册机是怎么工作的? 1. 关键词解释. Navicat激活公钥 这是一个2048位的RSA公钥,Navicat使用这个公钥来完成相关激活信息的加密和解密. 这个公钥 ...

  8. 微软与阿里云合作推出“开放应用模型(OAM)”

    英文原文:Announcing the Open Application Model (OAM) 原文标题:微软与阿里云合作推出“开放应用模型(OAM)” 用于 Kubernetes 及更多平台的应用 ...

  9. 在IIS中部署.net core应用

    在IIS中部署 .NET Core应用 对于熟悉IIS的程序员来说,将 .NET Core Web应用部署在IIS中,无疑是方便统一管理的事情.网上给出很多如何在IIS中部署 .NET Core 应用 ...

  10. unity3D开发环境搭建

    前言 本文记录unity3D开发环境的搭建 unity安装 unity有中文官网(https://unity.cn/),很贴心,ide工具我们选择下载安装中国区增强版,下载地址:https://uni ...