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 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<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#define inf 0x3f3f3f3f
using namespace std;
int compare(int x,int y,int z,int a,int b,int c)
{
if(x==a)
{
if(y==b)
{
if(z>=c)
return ;
else return ;
}
else if(y>b)
return ;
else return ;
}
else if(x>a)
return ;
else
return ;
} int main()
{
int n;
while(cin>>n)
{
string mi,ma;
int ai=,bi=,ci=;
int aa=,ba=,ca=;
for(int i=;i<=n;i++)
{
string s;
cin>>s;
int a,b,c;
scanf("%d:%d:%d",&a,&b,&c);
if(compare(ai,bi,ci,a,b,c)==)
{
mi=s;
ai=a;
bi=b;
ci=c;
}
scanf("%d:%d:%d",&a,&b,&c);
if(compare(aa,ba,ca,a,b,c)==)
{
ma=s;
aa=a;
ba=b;
ca=c;
}
}
cout<<mi<<" "<<ma;
}
return ;
}
1006 Sign In and Sign Out (25)(25 分)思路:普通的时间比较题。。。的更多相关文章
- 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 ...
- 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 ...
- 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 (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 ...
- 1006. Sign In and Sign Out (25)
At the beginning of every day, the first person who signs in the computer room will unlock the door, ...
- pat 1006 Sign In and Sign Out (25)
At the beginning of every day, the first person who signs in the computer room will unlock the door, ...
- 1006 Sign In and Sign Out (25)(25 point(s))
problem At the beginning of every day, the first person who signs in the computer room will unlock t ...
- 1006.Sign in and Sign out(25)—PAT 甲级
At the beginning of every day, the first person who signs in the computer room will unlock the door, ...
随机推荐
- 在微信里面打开链接,显示501 Not Implemented,但是同样的链接在其他浏览器是可以打开的。
在微信里面打开链接,显示501 Not Implemented,但是同样的链接在其他浏览器是可以打开的. 显示: 还原:该链接在2017年之前微信还是可以访问的. 访问的地址格式是:http://xx ...
- Python中列表生成式和字典生成式练习
(一)列表生成式 练习一:编写名为collatz(number)的函数:实现的功能:参数为偶数时,打印number// 2;参数为奇数时,打印3*number + 1 解析: number = int ...
- ADO Recordset 对象链接
http://baike.baidu.com/link?url=4Xdc46R8M5uj-BbOGaH761N5oDEYlGQJFeR2WbPwx1iQBusAUKU3qbWcHZCMmayatj9n ...
- HAWQ + MADlib 玩转数据挖掘之(三)——向量
一.定义 这里不讨论向量严格的数学定义.在Madlib中,可以把向量简单理解为矩阵.矩阵是Madlib中数据的基本格式,当矩阵只有一维时,就是向量,1行n列的矩阵称为行向量,m行1列的矩阵称为列向量, ...
- HAWQ取代传统数仓实践(十九)——OLAP
一.OLAP简介 1. 概念 OLAP是英文是On-Line Analytical Processing的缩写,意为联机分析处理.此概念最早由关系数据库之父E.F.Codd于1993年提出.OLAP允 ...
- 判断序列是否为二叉排序树的后序遍历 python
题目:给定一个序列,判断其是不是一颗二叉排序树的后序遍历结果 分析:首先要知道什么是排序二叉树,二叉排序树是这样定义的,二叉排序树或者是一棵空树,或者是具有下列性质的二叉树: (1)若左子树不空,则左 ...
- HslCommunication库的二次协议扩展,适配第三方通讯协议开发,基础框架支持长短连接模式
本文将使用一个gitHub开源的项目来扩展实现二次协议的开发,该项目已经搭建好了基础层架构,并实现了三菱,西门子,欧姆龙,MODBUS-TCP的通讯示例,也可以参照这些示例开发其他的通讯协议,并Pul ...
- iOS-----解决Prefix Header出错的问题
我们在使用 Prefix Header 预编译文件时有时会遇到如下的报错 clang: error: no such file or directory: '/Users/linus/Dropbox/ ...
- Python环境准备(安装python解释器)
上篇文章介绍了Python的相关知识,本章就开始着手操作,创建第一个Python程序,在这之前,首先需要配置Python的运行环境,也就是安装python解释器 ------------- 完美的分割 ...
- 如何修改localhost为自己指定的域名
一般在windows电脑中localhost的配置一般都在电脑的C:\Windows\System32\drivers\etc这个路径下 进入后,打开hosts文件通过编辑器或者其他的软件打开,打开 ...