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 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 分)的更多相关文章
- PAT 甲级 1006 Sign In and Sign Out
https://pintia.cn/problem-sets/994805342720868352/problems/994805516654460928 At the beginning of ev ...
- 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 ...
- PAT甲级1006水题飘过
题目分析:由于不存在相同的两个时间(24:00:00和00:00:00不会同时存在),则我们假设两个全局变量存放到达的最早的时间和达到的最晚的时间,设置最早的初值为“23:59:59”,设置最晚的初值 ...
- PAT甲级题解-1097. Deduplication on a Linked List (25)-链表的删除操作
给定一个链表,你需要删除那些绝对值相同的节点,对于每个绝对值K,仅保留第一个出现的节点.删除的节点会保留在另一条链表上.简单来说就是去重,去掉绝对值相同的那些.先输出删除后的链表,再输出删除了的链表. ...
- PAT甲级——1135 Is It A Red-Black Tree (30 分)
我先在CSDN上面发表了同样的文章,见https://blog.csdn.net/weixin_44385565/article/details/88863693 排版比博客园要好一些.. 1135 ...
- 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 ...
- 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 ...
- 【PAT甲级】1116 Come on! Let's C (20分)
题意: 输入一个正整数N(<=10000),接着依次输入N个学生的ID.输入一个正整数Q,接着询问Q次,每次输入一个学生的ID,如果这个学生的ID不出现在之前的排行榜上输出Are you kid ...
- 【PAT甲级】1115 Counting Nodes in a BST (30分)(二叉查找树)
题意: 输入一个正整数N(<=1000),接着输入N个整数([-1000,1000]),依次插入一棵初始为空的二叉排序树.输出最底层和最底层上一层的结点个数之和,例如x+y=x+y. AAAAA ...
随机推荐
- Blender 画正四面体
正四面体打开“添加网格”菜单(Shift + A),然后选择“锥形”.将“顶点数”设置为3,将“半径1”保留为默认值1.000,将“半径2”设置为0.000.现在,将深度设置为 {根号2,约等于1.4 ...
- PS学习之如何把小姐姐塞进瓶子里
准备素材 开始制作 用PS新建一个国际通用纸张大小的画布 分辨率可以调为72 改变背景色 插入图片 水平居中对齐 插入木质素材 放大 覆盖之前的素材 调整图层顺序 创建剪切蒙版 对木桩添加曲线 设置立 ...
- myeclipse从svn导入文件报错:
Access restriction:The type JPEGCodec is not accessible due to restriction on required library C:\Pr ...
- Extend a root LVM partition online
There is also a quick remedy for the emergency situation when your root partition runs out of disk s ...
- Js 分别取一个数的百位,十位,个位
<!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8& ...
- day 4 Socket 和 NIO Netty
Scoket通信--------这是一个例子,可以在这个例子的基础上进行相应的拓展,核心也是在多线程任务上进行修改 package cn.itcast.bigdata.socket; import j ...
- 转载 React.createClass 对决 extends React.Component
先给出结论,这其实是殊途同归的两种方式.过去我们一般都会使用 React.createClass 方法来创建组件,但基于 ES6 的小小语法糖,我们还可以通过 extends React.Compon ...
- 推荐一些好的linux学习网站
菜鸟教程:这个网站有jsp,php,c,android等等入门教程,很适合入门的新手和想多学一门语言的人 传送门http://www.runoob.com/ linux命令那么多,怎么记,给一个lin ...
- 使用ipns 为ipfs 系统自定义域名
ipns 可以帮助我们进行寻址操作,但是默认的hashid 还是太长,不好记忆,ipns 同时也支持 基于域名的解析,我们添加txt 记录就可以方便的解决ipfs 文件访问地址难记的问题,使用的是 一 ...
- tensorflow学习笔记
常量的四则运算 import tensorflow as tf data1 = tf.constant(2) data2 = tf.constant(10) dataAdd=tf.add(data1, ...