PAT (Advanced Level) Practise 1006. Sign In and Sign Out (25)
来源:互联网 发布:淘宝的拍卖手表可信吗 编辑:程序博客网 时间:2024/06/11 01:41
1006. Sign In and Sign Out (25)
时间限制: 400 ms
内存限制: 65536 kB
代码长度限制: 16000 B
判题程序:Standard
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
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
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.
Examples
Input 3
CS301111 15:30:28 17:00:10
SC3021234 08:00:00 11:25:25
CS301133 21:45:00 21:58:40 Output SC3021234 CS301133
Notes
作者
CHEN, Yue
利用好scanf格式化输入。
#include <iostream>#include <algorithm>#include <map>#include <vector>#include <functional>#include <string>#include <cstring>#include <queue>#include <set>#include <stack>#include <cmath>#include <cstdio>#include <sstream>#include <iomanip>using namespace std;#define IOS ios_base::sync_with_stdio(false)#define TIE std::cin.tie(0)#define MIN2(a,b) (a<b?a:b)#define MIN3(a,b) (a<b?(a<c?a:c):(b<c?b:c))#define MAX2(a,b) (a>b?a:b)#define MAX3(a,b,c) (a>b?(a>c?a:c):(b>c?b:c))typedef long long LL;typedef unsigned long long ULL;const int INF = 0x3f3f3f3f;const double PI = 4.0*atan(1.0);const double eps = 1e-6;int M, h, m, s, t, t1, t2;char str[20],up[20],lp[20];int main(){ scanf("%d", &M); t1 = INF; t2 = 0; for (int i = 0; i < M; i++){ scanf(" %s", str); scanf("%d:%d:%d", &h, &m, &s); t = h * 3600 + m * 60 + s; if (t < t1){ t1 = t; strcpy(up, str); } scanf("%d:%d:%d", &h, &m, &s); t = h * 3600 + m * 60 + s; if (t > t2){ t2 = t; strcpy(lp, str); } } printf("%s %s\n", up, lp); //system("pause");}
0 0
- PAT (Advanced Level) Practise 1006 Sign In and Sign Out
- 1006. Sign In and Sign Out (25)——PAT (Advanced Level) Practise
- PAT (Advanced Level) Practise 1006. Sign In and Sign Out (25)
- PAT (Advanced Level) Practise 1006. Sign In and Sign Out (25)
- PAT (Advanced Level) Practise 1006. Sign In and Sign Out (25)
- 【PAT Advanced Level】1006. Sign In and Sign Out (25)
- 【PAT (Advanced Level)】1006. Sign In and Sign Out (25)
- 【PAT】【Advanced Level】1006. Sign In and Sign Out (25)
- PAT (Advanced Level) Practise 1006Sign In and Sign Out (25)
- PAT-PAT (Advanced Level) Practise 1006. Sign In and Sign Out (25) (简单题)【一星级】
- PAT(Advanced level) 1006. Sign In and Sign Out
- 浙大 PAT Advanced level 1006. Sign In and Sign Out
- PAT (Advanced) 1006. Sign In and Sign Out (25)
- 【c++】PAT (Advanced Level) 1006. Sign In and Sign Out (25)
- PAT (Advanced Level) 1006. Sign In and Sign Out (25) 字符串比较
- PAT (Advanced Level) 1006. Sign In and Sign Out (25) 解题报告
- Pat(Advanced Level)Practice--1006(Sign In and Sign Out)
- PAT Advanced Level 1006:Sign In and Sign Out
- 在Android项目中新建一个Activity
- Jmeter:几项重要测试指标含义
- Java中断点下载使用类RandomAccessFile
- Gson解析json数据
- leetcode
- PAT (Advanced Level) Practise 1006. Sign In and Sign Out (25)
- java.net.BindException: Address already in use: bind
- android 选取本地视频或图片
- php解决时间不正确问题,设置中国时区
- 母牛的故事
- CSS选择器介绍
- Ubuntu下使用sed命令处理文本
- MD5加密工具类 UTF-8编码格式签名 UTF-8编译和反编译
- 怎样设置windows桌面自动刷新