PAT甲级——1006 Sign In and Sign Out
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<cstdio>
#include<iostream>
using namespace std;
struct pNode{
char ID[20];
int hh;
int mm;
int ss;
} temp,ans1,ans2;
bool compare(pNode node1,pNode node2)
{
if(node1.hh!=node2.hh) return node1.hh>node2.hh;
if(node1.mm!=node2.mm) return node1.mm>node2.mm;
return node1.ss>node2.ss;
}
int main()
{
ans1.hh=23;
ans1.mm=59;
ans1.ss=59;
ans2.hh=00;
ans2.mm=00;
ans2.ss=00;
int N;
cin>>N;
for(int i=0;i<N;i++)
{
scanf("%s %d:%d:%d",temp.ID,&temp.hh,&temp.mm,&temp.ss);
if(compare(temp,ans1)==false)
{
ans1 = temp;
}
scanf("%d:%d:%d",&temp.hh,&temp.mm,&temp.ss);
if(compare(temp,ans2)==true)
{
ans2 = temp;
}
}
printf("%s %s\n",ans1.ID,ans2.ID);
return 0;
}
PAT甲级——1006 Sign In and Sign Out的更多相关文章
- 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 ...
- PAT 甲级 1006 Sign In and Sign Out
https://pintia.cn/problem-sets/994805342720868352/problems/994805516654460928 At the beginning of ev ...
- PAT甲级1006水题飘过
题目分析:由于不存在相同的两个时间(24:00:00和00:00:00不会同时存在),则我们假设两个全局变量存放到达的最早的时间和达到的最晚的时间,设置最早的初值为“23:59:59”,设置最晚的初值 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- SQL基础教程(第2版)第6章 函数、谓词、CASE表达式:6-2 谓词
● 谓词就是返回值为真值的函数. ● 可以将子查询作为IN和EXISTS的参数. 本节将会和大家一起学习 SQL 的抽出条件中不可或缺的工具——谓词(predicate).例如, =. <. & ...
- python logging的输出
---恢复内容开始--- python中logging的使用 什么是日志: 日志是一种可以追踪某些软件运行时所发生事件的方法 软件开发人员可以向他们的代码中调用日志记录相关的方法来表明发生了某些事情 ...
- UML-UML工具与UML蓝图
1.UML应用场景 1).UML作为草图 2).UML作为蓝图. UML生成java代码(前向工程) java代码生成UML(逆向工程) 2.如果绘制了UML草图,如何在编码后更新该图形? 逆向工程, ...
- 萤火虫系统(firefly) RK3399 python3 安装 spicy
最近一直在研究深度学习,公司里正好也有个项目是需要在RK3399的板子上跑人脸识别. 原本在linux_x86系统上轻轻松松装的环境到了RK3399板子上(firefly系统)安装起来真的非常麻烦,需 ...
- python 用 pycharm 光速下载各种包
https://blog.csdn.net/z1178517021/article/details/80200999 就是这么简单
- min25筛学习笔记
min25筛简介:用来求积性函数F(x)前缀和的,复杂度O(n0.75/logn),大概能求n<=1010. 记一个数x的最小质因子为R(x),所以当x不为质数时,R(x)<=√x这是废话 ...
- 树状数组--模版1和2 P3368、P3374
题目描述 如题,已知一个数列,你需要进行下面两种操作: 将某一个数加上 x 求出某区间每一个数的和 输入格式 第一行包含两个正整数 n,m,分别表示该数列数字的个数和操作的总个数. 第二行包含 n 个 ...
- 邮件发送,无尽的501错误。TCP发送邮件解决方案
先贴上错误信息,便于搜索引擎采集,也送给遇到此问题的技术朋友们. smtp 501 Syntax error (no parameters allowed) (#5.5.4) 背景描述: 使用TCP发 ...
- slideshare文档下载
if [ x"$1" = x1 ]; then for i in {1..46}; do url_i="https://image.slidesharecdn.com/b ...
- LUA函数闭包
词法定界:当一个函数内嵌套另一个函数的时候,内函数可以访问外部函数的局部变量,这种特征叫做词法定界 table.sort(names,functin (n1,n2) return grades[n1] ...