1006.Sign in and Sign out(25)—PAT 甲级
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
题目大意:在一堆开门关门的员工中,分别找到最早开门和最晚关门的员工号.
分析:利用c++string类型用字典序进行比较的特性直接比较开门时间和关门时间,temp_unlock和temp_lock分别是比较开门时间和关门时间的临时变量,first_unlock和last_lock分别用来记录最早开门和最晚开门的员工号。
#include <iostream>
using namespace std;
int main() {
string first_unlock,final_lock;
int m;
scanf("%d",&m);
string id_number,unlock,lock;
string temp_unlock="9",temp_lock="0";
for(int i=0;i<m;i++)
{
cin>>id_number>>unlock>>lock;
if(unlock<temp_unlock){
temp_unlock=unlock;
first_unlock=id_number;
}
if(lock>temp_lock){
temp_lock=lock;
final_lock=id_number;
}
}
cout<<first_unlock<<" "<<final_lock<<endl;
return 0;
}
1006.Sign in and Sign out(25)—PAT 甲级的更多相关文章
- Count PAT's (25) PAT甲级真题
题目分析: 由于本题字符串长度有10^5所以直接暴力是不可取的,猜测最后的算法应该是先预处理一下再走一层循环就能得到答案,所以本题的关键就在于这个预处理的过程,由于本题字符串匹配的内容的固定的PAT, ...
- PAT甲级题解(慢慢刷中)
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...
- 【转载】【PAT】PAT甲级题型分类整理
最短路径 Emergency (25)-PAT甲级真题(Dijkstra算法) Public Bike Management (30)-PAT甲级真题(Dijkstra + DFS) Travel P ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- Angular1.x 基础总结
官方文档:Guide to AngularJS Documentation w3shools angularjs教程 wiki <AngularJS权威教程> Introd ...
- Selenium之TestNG安装
一.在Eclipse中安装TestNG 1.打开eclipse-->help-->Install New Software-->Add,输入Name和Location后,点击OK. ...
- flask代码统计作业
用户表: create table userInfo( id int not null unique auto_increment, name )not null, password ) not nu ...
- mysql中int、bigint、smallint 和 tinyint的区别与长度的含义【转】
最近使用mysql数据库的时候遇到了多种数字的类型,主要有int,bigint,smallint和tinyint.其中比较迷惑的是int和smallint的差别.今天就在网上仔细找了找,找到如下内容, ...
- 打通版微社区(3):在Web服务器上部署memcache For DZ3.2
写在前面:首先这个数据库加速程序的原理,是将数据库内容缓存到Web服务器的内存上,也就是内存换速度.我本次微社区的应用其实应该用不了这个,只是看到好多DZ论坛部署的都安装了这个,我就练手一下以便不时之 ...
- LNMP-day2-进阶
部署LNMP环境 http://www.cnblogs.com/wazy/p/8386493.html 安装部署wordpress #下载wordpress [root@locahost downlo ...
- ZT 匿名内存映射
mmap函数使用 分类: Linux/Unix C/C++ 2008-01-22 17:03 6089人阅读 评论(1) 收藏 举报 unix编程null网络 UNIX网络编程第二卷进程间通信对mma ...
- 编程题A+B Format的总结(第二次作业<一>)
Github链接地址:https://github.com/Startup-try/object-oriented 这个题目现在想想没有那么难,其实还挺简单的,但是中午花了好长的时间还不懂得怎么做,感 ...
- Linux中如何配置sudo用户
Linux中的sudo文件在/etc/sudoers,但不建议直接修改此文件: 可以在/etc/sudoers.d文件夹中新建文件,文件名随意,在文件中添加内容如下: 用户名 ALL=(ALL) AL ...
- yarn logs -applicationId [applicationID]
yarn logs -applicationId application_1435648583743_0001 报错: tmp/logs/.../application_1435648583743_0 ...