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. java输出乱码专题

    https://blog.csdn.net/liaoYu1887/article/details/82714727(其他) @Controller public class ItemCatContro ...

  2. 2018 焦作网络赛 G Give Candies ( 欧拉降幂 )

    题目链接 题意 : 给出 N 个糖果.老师按顺序给 1~N 编号的学生分配糖果.每个学生要么不分.要么最少分一个.且由于是按顺序发放.那么对于某个有分到糖果的编号为 i 的学生.则 1~(i-1) 这 ...

  3. 响应式web布局

    通过不同的媒体类型和条件定义样式表规则,媒体查询让CSS可以更精确作用于不同的媒体类型和同一媒体的不同条件.媒体查询的大部分媒体特性都接受min和max用于表达”大于或等于”和”小与或等于”.如:wi ...

  4. Hibernate和Mybatis框架的对比

    Hibernate:是一个标准的ORM(对象关系映射)框架.入门门槛较高,不需要程序员写sql,sql语句自动生成.但是就造成对sql语句进行优化.修改比较困难.应用场景:适用于需求变化不多的中小型项 ...

  5. vue子组件改变父组件的值

    1 在父组件的coment绑定事件 <template> <div :class="classObj" class="app-wrapper" ...

  6. badboy——jmeter录制工具

    web网站录制工具 输入网址:红点点被选中代表在录制,然后点点点: 然后导出: 在从JMETER打开:(注意,一定要填cookie)

  7. This sample is for changing from “float64” to “int” for values did unmarshal using map[string]interface{}. When it did unmarshal using map[string]interface{}, a number with “int” was changed to “floa

    This sample is for changing from “float64” to “int” for values did unmarshal using map[string]interf ...

  8. Java-synchronized 中锁的状态及其转换

    synchronized 锁的优化过程:无锁 -> 偏向锁 -> 轻量级锁 -> 重量级锁 一.不同锁对象的状态表示(需要了解 Java 对象头) https://wiki.open ...

  9. java html table 转 excel,给予jdom 和 poi

    maven 引入 <dependency> <groupId>org.jdom</groupId> <artifactId>jdom</artif ...

  10. leetcode315 计算右侧小于当前元素的个数

    1. 采用归并排序计算逆序数组对的方法来计算右侧更小的元素 time O(nlogn): 计算逆序对可以采用两种思路: a. 在左有序数组元素出列时计算右侧比该元素小的数字的数目为 cnt=r-mid ...