码迷,mamicode.com
首页 > 其他好文 > 详细

1006. Sign In and Sign Out (25)(技巧性模拟)

时间:2017-05-06 00:49:31      阅读:324      评论:0      收藏:0      [点我收藏+]

标签:test   ecif   gif   img   closed   技巧性   fence   ica   nsis   

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

 技术分享

Code:

技术分享
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 string open = "23:59:59";
 4 string close = "00:00:00";
 5 string a , b , id , ans_o , ans_c;
 6 int main()
 7 {
 8     int n;
 9     scanf("%d" , &n);
10     for(int i = 1 ; i <= n ; ++i)
11     {
12         cin >> id >> a >> b;
13         if(a < open)
14         {
15             open = a;
16             ans_o = id;
17         }
18         if(b > close)
19         {
20             close = b;
21             ans_c = id;
22         }
23     }
24     cout << ans_o << " " << ans_c;
25 }
View Code

 

1006. Sign In and Sign Out (25)(技巧性模拟)

标签:test   ecif   gif   img   closed   技巧性   fence   ica   nsis   

原文地址:http://www.cnblogs.com/jianglingxin/p/6815158.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!