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 ...
随机推荐
- Node.js内置的文件系统模块(fs)
异步读取文件 按照js的标准,异步读取一个文本文件的格式如下: 'use strict' const fs = require('fs') fs.readFile('test.txt', 'utf-8 ...
- Linux下mysql出错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
安装: 1.新开的云服务器,需要检测系统是否自带安装mysql # yum list installed | grep mysql 2.如果发现有系统自带mysql,果断这么干 # yum -y re ...
- Maven命令安装jar包到本地仓库
https://blog.csdn.net/moxiong3212/article/details/78767480 当需要的jar包在中央仓库找不到或者是想把自己生成的jar包放到的Maven仓库中 ...
- MySQL--查看数据库连接信息
===================================== 查看当前连接到数据库的用户和Host ## 查看当前连接到数据库的用户和Host ## SELECT DISTINCT US ...
- php-cgi和php-fpm,Windows环境下解决Nginx+php并发访问阻塞问题。
php-cgi 是运行php,php-fpm是守护php-cgi进程 nginx配置目录运行php location ~ \.php$ { ...
- async await 的 实质 本质
async await 的 实质 就是 用 “状态机” 来 取代 函数层层调用 . async await 的 本质 是 语法糖, 和 提高性能 什么的 没什么关系 . 为了避免理解歧义, 我把 ...
- TweenMax 动画库,知识点
官方地址:https://greensock.com/tweenmax github 地址:https://github.com/greensock/GreenSock-JS 比较好的介绍文章: ht ...
- java 字符集 Charset
字符集就是为每个字符编个号码.如ASCII编码中,字符 'A' 的号码为 65 (或二进制01000001):GBK编码中,字符 '国' 对应的号码为47610 . 编码:将字符序列转换成二进制序列. ...
- Android 单元测试覆盖率计算
在工程下面的build.gradle 增加配置 1.增加Plugin apply plugin: 'jacoco' 2. 增加jacoco版本 jacoco{ version "0.7.4. ...
- mysql二进制日志详解
一.什么是二进制日志 二进制日志主要记录mysql数据库的变化,二进制日志包含所有更新了数据或者潜在更新了数据(如没有匹配到任何行的delete语句),语句以时间的形式保存,描述了数据的更改.二进制日 ...