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
思路
代码
#include<bits/stdc++.h>
using namespace std;
struct node
{
char name[20];
int hh,mm,ss;
}small, big; void Init()
{
big.hh = big.mm = big.ss = 0;
small.hh = 24;
small.mm = small.ss = 59;
} bool early(node a, node b)
{ //true-a的时间早于b的时间
if(a.hh != b.hh) return a.hh <= b.hh;
else if(a.mm != b.mm) return a.mm <= b.mm;
else return a.ss <= b.ss;
}
int main()
{
int m;
cin >> m;
Init(); node tmp;
while(m--)
{
scanf("%s %d:%d:%d", &tmp.name, &tmp.hh, &tmp.mm, &tmp.ss);
if(early(tmp, small))
small = tmp; //更新最早
scanf("%d:%d:%d", &tmp.hh, &tmp.mm, &tmp.ss);
if(early(big, tmp))
big = tmp; //更新最晚
}
cout << small.name << " " << big.name;
return 0;
}
引用

https://pintia.cn/problem-sets/994805342720868352/problems/994805516654460928

PTA(Basic Level)1006.Sign In and Sign Out的更多相关文章

  1. 来自PTA Basic Level的三只小野兽

    点我阅读原文 最近利用闲暇时间做了一下 PTA Basic Level[1] 里的题,里面现在一共有 95 道题,这些题大部分很基础,对于刷倦了 leetcode 的小伙伴可以去里面愉快的玩耍哦. 这 ...

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

  3. PTA(Basic Level)1020.月饼

    月饼是中国人在中秋佳节时吃的一种传统食品,不同地区有许多不同风味的月饼.现给定所有种类月饼的库存量.总售价.以及市场的最大需求量,请你计算可以获得的最大收益是多少. 注意:销售时允许取出一部分库存.样 ...

  4. PTA(Basic Level)1057.数零壹

    给定一串长度不超过 105 的字符串,本题要求你将其中所有英文字母的序号(字母 a-z 对应序号 1-26,不分大小写)相加,得到整数 N,然后再分析一下 N 的二进制表示中有多少 0.多少 1.例如 ...

  5. PTA(Basic Level)-1002 写出这个数

    一 1002 写出这个数  读入一个正整数 n,计算其各位数字之和,用汉语拼音写出和的每一位数字. 输入格式: 每个测试输入包含 1 个测试用例,即给出自然数 n 的值.这里保证 n 小于 10​10 ...

  6. PTA(Basic Level)-1076 Wifi密码

    一 题目介绍:     现将 wifi 密码设置为下列数学题答案:A-1:B-2:C-3:D-4.本题就要求你写程序把一系列题目的答案按照卷子上给出的对应关系翻译成 wifi 的密码.这里简单假设每道 ...

  7. PTA(Basic Level)1039.到底买不买

    小红想买些珠子做一串自己喜欢的珠串.卖珠子的摊主有很多串五颜六色的珠串,但是不肯把任何一串拆散了卖.于是小红要你帮忙判断一下,某串珠子里是否包含了全部自己想要的珠子?如果是,那么告诉她有多少多余的珠子 ...

  8. PTA(Basic Level)1033.旧键盘打字

    旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现.现在给出应该输入的一段文字.以及坏掉的那些键,打出的结果文字会是怎样? 输入格式: 输入在 2 行中分别给出坏掉的那些键.以及应该输入 ...

  9. PTA --- Basic Level 1009 说反话

    1009 说反话 (20 point(s))   给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出. 输入格式: 测试输入包含一个测试用例,在一行内给出总长度不超过 80 的字符串.字符串由 ...

随机推荐

  1. js中Array的sort方法

    Array.sort方法里需要传入一个参数,是一个function, 如果想要升序排序,就传入这样的一个function: function sortFunction(a,b){ return a-b ...

  2. 分析 JUnit 框架源代码

    本文转载至http://www.ibm.com/developerworks/cn/java/j-lo-junit-src/ 分析 JUnit 框架源代码 理解 JUnit 测试框架实现原理和设计模式 ...

  3. ZOJ 2967计算几何+单调栈

    ZOJ - 2967Colorful Rainbows 题目大意:给你道彩虹,每条彩虹有两个属性,a斜率和b截距,也就是彩虹描述为y=ax+b的直线,并且不存在垂直的彩虹以及一样的彩虹.然后就说明,如 ...

  4. python多环境切换,pyenv的使用

    1.安装pyenv:https://github.com/pyenv/pyenv-installer curl -L https://github.com/pyenv/pyenv-installer/ ...

  5. Java当中的IO流-时间api(下)-上

    Java当中的IO流(下)-上 日期和时间 日期类:java.util.Date 系统时间: long time = System.currentTimeMillis(); public class ...

  6. Lucas(卢卡斯)定理

    Lucas定理 对于C(m,n)%P(P是质数)这样的问题,可以通过预处理阶乘和阶乘的逆元,来快速计算.但是当m,n大于P时,就不能保证m,n与P互质了,但不互质的情况下,乘法逆元不存在,此时就需要卢 ...

  7. Nmap简单的漏扫

    转载至 https://www.4hou.com/technology/10481.html   导语:Nmap本身内置有丰富的NSE脚本,可以非常方便的利用起来,当然也可以使用定制化的脚本完成个人的 ...

  8. Android学习_Fragment

    Fragment 使用Fragment 我们可以把屏幕划分成几块,然后进行分组,进行一个模块化的管理.从而可以更加方便的在运行过程中动态地更新Activity的用户界面.另外Fragment并不能单独 ...

  9. python2topython3遇到的问题

  10. Android 获取Bitmap方式

    1.获得当前项目资源文件(assets)下图片 (1).获得图片数据流 private Bitmap getBotMapInfo() { Bitmap bitmap = null; try { Inp ...