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<string> using namespace std; struct record
{
string idNumber;
int comeTime;
int leaveTime; record()
{
comeTime=;
leaveTime=;
idNumber = " ";
} //将字符串时间变为整型时间
void init(string str1,string str2,string str3)
{
idNumber = str1; for(int i=;i<;++i)
{
if(i!= && i!=)
{
comeTime = *comeTime+str2[i]-;
leaveTime = *leaveTime+str3[i]-;
}
}
}
}; int main()
{
int n,min=,max=;
string str1,str2,str3,firstID,lastID; cin>>n; record *p =new record[n]; for(int i=;i<n;++i)
{
cin>>str1>>str2>>str3; p[i].init(str1,str2,str3); if(p[i].comeTime < min)
{
firstID=p[i].idNumber;
min = p[i].comeTime;
} if(p[i].leaveTime > max)
{
lastID = p[i].idNumber;
max = p[i].leaveTime;
}
} cout<<firstID<<" "<<lastID<<endl; delete[] p; return ;
}

PAT 甲级 1006 Sign In and Sign Out (25)(25 分)的更多相关文章

  1. PAT 甲级 1006 Sign In and Sign Out

    https://pintia.cn/problem-sets/994805342720868352/problems/994805516654460928 At the beginning of ev ...

  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甲级1006水题飘过

    题目分析:由于不存在相同的两个时间(24:00:00和00:00:00不会同时存在),则我们假设两个全局变量存放到达的最早的时间和达到的最晚的时间,设置最早的初值为“23:59:59”,设置最晚的初值 ...

  4. PAT甲级题解-1097. Deduplication on a Linked List (25)-链表的删除操作

    给定一个链表,你需要删除那些绝对值相同的节点,对于每个绝对值K,仅保留第一个出现的节点.删除的节点会保留在另一条链表上.简单来说就是去重,去掉绝对值相同的那些.先输出删除后的链表,再输出删除了的链表. ...

  5. PAT甲级——1135 Is It A Red-Black Tree (30 分)

    我先在CSDN上面发表了同样的文章,见https://blog.csdn.net/weixin_44385565/article/details/88863693 排版比博客园要好一些.. 1135 ...

  6. PAT 甲级 1043 Is It a Binary Search Tree (25 分)(链表建树前序后序遍历)*不会用链表建树 *看不懂题

    1043 Is It a Binary Search Tree (25 分)   A Binary Search Tree (BST) is recursively defined as a bina ...

  7. PAT 甲级 1033 To Fill or Not to Fill (25 分)(贪心,误以为动态规划,忽视了油量问题)*

    1033 To Fill or Not to Fill (25 分)   With highways available, driving a car from Hangzhou to any oth ...

  8. 【PAT甲级】1116 Come on! Let's C (20分)

    题意: 输入一个正整数N(<=10000),接着依次输入N个学生的ID.输入一个正整数Q,接着询问Q次,每次输入一个学生的ID,如果这个学生的ID不出现在之前的排行榜上输出Are you kid ...

  9. 【PAT甲级】1115 Counting Nodes in a BST (30分)(二叉查找树)

    题意: 输入一个正整数N(<=1000),接着输入N个整数([-1000,1000]),依次插入一棵初始为空的二叉排序树.输出最底层和最底层上一层的结点个数之和,例如x+y=x+y. AAAAA ...

随机推荐

  1. HDU2027:统计元音

    Problem Description 统计每个元音字母在字符串中出现的次数. Input 输入数据首先包括一个整数n,表示测试实例的个数,然后是n行长度不超过100的字符串. Output 对于每个 ...

  2. sparkStreaming获取kafka数据(java版本)

    环境 spark-2.2.0 kafka_2.11-0.10.0.1 jdk1.8 配置好jdk,创建项目并将kafka和spark的jar包添加到项目中,除此之外还需要添加spark-streami ...

  3. Blender的单位:一图弄懂Blender的单位

    1设置单位,在右边的场景设置里,可以设置公制,英制.下面还可以设置基础单位长度,就是单位网格对应的长度. 2显示单位,按N出现在右边的属性栏里,可以设置选中的显示长度及角度. 3测量,按T出现在左边d ...

  4. 实验吧—密码学——WP之 困在栅栏里的凯撒

    首先我们研究题目.栅栏:凯撒 还发现一个数字“6”,那么我们很容易就有一个解题思路 对这段字符进行栅栏解密再进行凯撒解密 我们都知道,栅栏解密的关键就是栏数,根据题目中我们发现的信息,这段字符串是12 ...

  5. python与系统做交互常用的模块和使用方法

    1.使用os模块与系统做简单命令的交互 >>>import os >>>os.popen('pwd') <open file 'pwd', mode 'r' ...

  6. codeforces 788A Functions again

    …… 原题: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandia ...

  7. itcast-Hibernate orm元数据和 关系操作

    在Hibernate安装包 project /etc/hibernate.property文件下 显示 ,格式化       映射导入映射文件 详解orm元数据 配置文件详解 generator主键生 ...

  8. Java基础二(变量、运算符)

    1.变量2.运算符 ###01变量概述 * A: 什么是变量? * a: 变量是一个内存中的小盒子(小容器),容器是什么?生活中也有很多容器,例如水杯是容器,用来装载水:你家里的大衣柜是容器,用来装载 ...

  9. MySQL Transaction--事务相关查询

    MySQL支持的四种事务隔离级别 READ-UNCOMMITTED READ-COMMITTED REPEATABLE-READ SERIALIZABLE 查看全局事务隔离级别和会话事务隔离级别 SH ...

  10. MySQL--Semi-join(半连接)优化策略

    Semi-join(半连接)半连接主要场景:检查一个结果集(外表)的记录是否在另外一个结果集(字表)中存在匹配记录,半连接仅关注”子表是否存在匹配记录”,而并不考虑”子表存在多少条匹配记录”,半连接的 ...