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. 02 JDBC相关

    ====================================================================================JDBC JAVA Databa ...

  2. C++学习(二十三)(C语言部分)之 指针4

    指针 指针 存放地址 只能存放地址 使用 &取地址运算符 *取值 解引用运算符 malloc 申请堆内存 free释放堆内存 1.1 指针 存放的地址(变量地址 常量区的地址 堆区内存首地址 ...

  3. SimpleDateFormat未抛出ParseException

    关于SimpleDateFormat的不严格性[技术探讨]今天一组员写了几段Java代码,发现如下问题:        SimpleDateFormat sdf = new SimpleDateFor ...

  4. 【java多线程】队列系统之LinkedBlockingQueue源码

    转载:https://blog.csdn.net/tonywu1992/article/details/83419448 http://benjaminwhx.com/archives/ 1.简介 上 ...

  5. linqpad使用方法备忘

    1.使用EF更新数据库 void Main() { select item).ToList(); CM_BookPages.DeleteAllOnSubmit(items); SubmitChange ...

  6. hibernate(一)

      hibernate介绍 jdbc缺点 1代码结构防繁琐,面向纯sql语句的编程,对于查询而言只要查询数据库的一张表,不需有如下编码 2有connection缓存,没有数据缓存 3.事务自动开启,有 ...

  7. elasticsearch技术解析与实战(一) 入门和索引

    GET _cat/nodes GET _cat/health GET _cat/shards GET http://10.37.84.124:9200/secisland?pretty { " ...

  8. buckaroo 试用

    我系统是mac 所以选择的是mac 的版本,官方是支持跨平台的. 安装 mac 版本安装 wget https://github.com/LoopPerfect/buckaroo/releases/d ...

  9. js技巧专题篇: 页面跳转

    本篇主要介绍网页上常见的页面跳转技术.页面跳转有几种方式,比较常用的是window.location.href,window.location.replace,window.open,当然还有目前比较 ...

  10. 装饰模式Decorator Pattern

    1.主要优点 装饰模式的主要优点如下: (1) 对于扩展一个对象的功能,装饰模式比继承更加灵活性,不会导致类的个数急剧增加. (3) 可以对一个对象进行多次装饰,通过使用不同的具体装饰类以及这些装饰类 ...