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. windows使用cmd查看、杀死进程

    查看某个进程: netstat -ano | findstr  端口号 杀死某个进程: taskkill /f  /pid  进程号

  2. Python学习笔记(四)——文件永久存储

    文件的永久存储 pickle模块的使用 pickle的实质就是将数据对象以二进制的形式存储 存储数据 pickle.dump(data,file) data表示想要存储的数据元素,file表示要将数据 ...

  3. python_django_models模块中的查询

    查询集:表示从数据库获取的对象集合,查询集可以有多个过滤器,过滤器就是一个函数(方法),基于所给参数限制查询集结果 从sql角度来说,查询集和select等价,过滤器和where等价 查询集特点: 惰 ...

  4. vue-router如何参数传递

    1.我们用<router-link>标签中的to属性进行传参,需要您注意的是这里的to要进行一个绑定,写成:to 先来看一下这种传参方法的基本语法: <router-link :to ...

  5. js结巴程序

    var str="我.....我是一个个......帅帅帅帅哥!"; var reg=/\./gi; str=str.replace(reg,""); reg= ...

  6. day28 import,from * import *,__name__

    Python之路,Day16 = Python基础16 一 module通常模块为一个文件,直接使用import来导入就好了.可以作为module的文件类型有".py"." ...

  7. (转)第05节:Fabric.js的动画设置

    凡是出色的Canvas库都少不了制作动画的方法,Fabric.js也不例外,它有着编写简单且功能强大的动画助手,这就是animate( )方法. animate主要使用代码如下: rect.anima ...

  8. 牛客多校第六场 J Upgrading Technology dp

    题意: 有n个技能,一开始都是0级,第i个技能从j-1级升到j级,花费$c_{i,j}$,但是花费不一定是正的 所有的技能升到j级时,奖励$d_j$但是奖励也不一定是正的 题解: 用sum[i][j] ...

  9. Windbg Step 2 分析程序堆栈实战

    #include "stdafx.h" #include <tchar.h> #ifdef _UNICODE #define _ttol _wtol #else #de ...

  10. 多线程的基本概念和Delphi线程对象Tthread介绍

    多线程的基本概念和Delphi线程对象Tthread介绍 作者:xiaoru    WIN 98/NT/2000/XP是个多任务操作系统,也就是:一个进程可以划分为多个线程,每个线程轮流占用CPU运行 ...