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 <string> using namespace std; //很简单,就是找到来的最早的人和回去最晚的人即可
int getTime(string Time)
{
//由于时间时标准输入,所以很好计算
return ((Time[] - '') * + (Time[] - '')) * * +
((Time[] - '') * + (Time[] - '')) * +
(Time[] - '') * + (Time[] - ''); } int main()
{
int M;
cin >> M;
string firstMan, lastMan;
int firstTime, lastTime;
firstTime = * * + ;//24小时多一秒,属于第二天了
lastTime = -;//属于前一天
string No, InTime, OutTime;
for (int i = ; i < M; ++i)
{
cin >> No >> InTime >> OutTime;
if (firstTime > getTime(InTime))
{
firstTime = getTime(InTime);
firstMan = No;
}
if (lastTime < getTime(OutTime))
{
lastTime = getTime(OutTime);
lastMan = No;
}
}
cout << firstMan << " " << lastMan << endl;
return ;
}
 

PAT甲级——A1006 Sign In and Sign Out的更多相关文章

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

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

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

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

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

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

  7. PAT甲级题解(慢慢刷中)

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  8. PAT 甲级真题题解(1-62)

    准备每天刷两题PAT真题.(一句话题解) 1001 A+B Format  模拟输出,注意格式 #include <cstdio> #include <cstring> #in ...

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

随机推荐

  1. 001-Java命名规范

    1. 包名 多个单词都小写xxxyyyzzz 2.类名和接口名 多单词组成时,所有单词的首字母大写XxxYyyZzz 3.变量名和方法名 多单词组成时,第一个单词首字母小写,后面单词首字母军大写 xx ...

  2. 数据库MySQL--常见函数

    例子文件:https://files.cnblogs.com/files/Vera-y/myemployees.zip 函数:将一组逻辑语句封装在函数体中,对外暴露函数名 调用:select 函数名( ...

  3. 测试用例覆盖率converage

    当报如下错误: TypeError: 'ModuleImportFailure' object is not iterable 或者 TypeError: '_FailedTest' object i ...

  4. JavaScript - 常用对象相关

    1. String对象 length : 字符串的长度 charAt(index) : 返回指定位置的字符串, 下标从0开始 indexOf(str) : 返回指定的字符串在当前字符串中首次出现的位置 ...

  5. 计算几何——点线关系(叉积)poj2318

    #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #i ...

  6. python截图+百度ocr(图片识别)+ 百度翻译

    一直想用python做一个截图并自动翻译的工具,恰好最近有时间就在网上找了资料,根据资料以及自己的理解做了一个简单的截图翻译工具.整理一下并把代码放在github给大家参考.界面用python自带的G ...

  7. ON_EVENT 报错

    错误提示: error C2440: 'initializing' : cannot convert from 'const wchar_t [1]' to 'UINT' error C2440: ' ...

  8. 多进程并发socket通信

    实现多个客户端同时接入server端,并且可以同时向客户端发送信息 server端 def dunc(conn,client_addr): while True: data=conn.recv(102 ...

  9. Linux 后台运行python .sh等程序,以及查看和关闭后台运行程序操作

    1.运行.sh文件 直接用./sh 文件就可以运行,但是如果想后台运行,即使关闭当前的终端也可以运行的话,需要nohup命令和&命令. (1)&命令 功能:加在一个命令的最后,可以把这 ...

  10. Mac 解决硬盘插入不能写的问题

    软件解决 链接:https://pan.baidu.com/s/1H_zvPPpW0dp7aRUvjDnkQA  密码:8fit 有个NTFS的移动硬盘,默认Mac系统是不能写入,只能读取的,我们可以 ...