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 ...
随机推荐
- String和StringBuffer有什么区别
首先,String和StringBuffer主要有2个区别: (1)String类对象为不可变对象,一旦你修改了String对象的值,隐性重新创建了一个新的对象,释放原String对象,StringB ...
- 在datagridview中添加button按钮
.Net的DataGridView控件中,提供了一种列的类型,叫 DataGridViewButtonColumn ,这种列类型是展示为一个 按钮,可以给button赋予相应的text,并且,此but ...
- Django路由系统---django重点之url命名分组
django重点之url命名分组[参数无顺序要求]. settigs.py:增加STATICFILES_DIRS静态资源路径配置,名称为创建的文件夹名称 'DIRS': [os.path.join(B ...
- Handlebars.js中集合(list)通过中括号的方式取值
有这么一个需求,在一个table中,tr是通过each取值,取出的值要与table标题相对应,如何实现?例如: <table> <thead> <tr> {{#ea ...
- vector中删除的注意事项
erase的函数原型有两种形式: iterator erase(iterator position); iterator erase(iterator first, iterator last); 例 ...
- vue开发知识点汇总
网址: https://www.tuicool.com/articles/Zb2Qre2;
- vim 取消高亮
/ 匹配以后会一直有高亮,退出以后还是有: set nohlsearch nohlsearch
- 【[SDOI2011]拦截导弹】
这道题是真的蛇皮 方案数要开\(double\)真的蛇皮 首先\(dp\)是非常容易看出来的 设\(dp[i]\)表示以\(i\)结尾的最长子序列 显然转移方程为 \[dp[i]=max(dp[j]+ ...
- IE8崩溃在CElement::GetUpdatedLayoutWithContext
发了一个我们页游助手的版本时,测试报告在某些机器上点开某网站时崩溃 "0x637e5067指令引用的0x00000008内存,该内存不能为read",查看dump文件,堆栈如下: ...
- MAC下常用命令的中文帮助文档(man) 出现错误
MacdeMacBook-Pro:Desktop mac$ tar -xf manpages-zh-1.5.2.tar.bz2 MacdeMacBook-Pro:~ root# cd /Users/m ...