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; //很简单,就是找到来的最早的人和回去最晚的人即可
int getTime(string Time)
{
//由于时间时标准输入,所以很好计算
return ((Time[] - '') * + (Time[] - '')) * * +
((Time[] - '') * + (Time[] - '')) * +
(Time[] - '') * + (Time[] - ''); } int main()
{
int M;
cin >> M;
string firstMan, lastMan;
int firstTime, lastTime;
firstTime = * * + ;//24小时多一秒,属于第二天了
lastTime = -;//属于前一天
string No, InTime, OutTime;
for (int i = ; i < M; ++i)
{
cin >> No >> InTime >> OutTime;
if (firstTime > getTime(InTime))
{
firstTime = getTime(InTime);
firstMan = No;
}
if (lastTime < getTime(OutTime))
{
lastTime = getTime(OutTime);
lastMan = No;
}
}
cout << firstMan << " " << lastMan << endl;
return ;
}
 

最新文章

  1. sql奇进偶舍函数
  2. Javascript初学篇章_7(DOM)
  3. Mobile Web中URL设计问题
  4. PHPExcel对于Excel中日期和时间类型的处理
  5. Java字符串转换
  6. UML静态类图
  7. 练习2 G题 - 数值统计
  8. php基础知识【函数】(4)时间date
  9. [ES6] Array -- Destructuring and Rest Parameters &amp;&amp; for ..of &amp;&amp; Arrat.find()
  10. TBB入门
  11. container宽度
  12. C# 操作系统回收站
  13. FreeMarker 小结
  14. 学习笔记TF052:卷积网络,神经网络发展,AlexNet的TensorFlow实现
  15. scrapy_全站爬取
  16. java 零基础搭建dubbo运行环境
  17. Form 表单提交的几种方式
  18. 定时任务调度工作(学习记录 四)schedule与scheduleAtFixedRate的区别
  19. 软件测试之Soot
  20. 树形结构表的存储【转自:http://www.cnblogs.com/huangfox/archive/2012/04/11/2442408.html】

热门文章

  1. centos yum install 找不到软件包
  2. digitalpersona 开发(系统托盘,监听指纹扫描)
  3. The linux command之环境
  4. sql(11) sum
  5. scala中的闭包简单使用
  6. C++ 贪吃蛇二维
  7. 单独编译和使用webrtc音频降噪模块(附完整源码+测试音频文件)
  8. python定时任务模块APScheduler
  9. Windows便筏快捷键
  10. (1)mysql数据库操作