PAT甲 1006. Sign In and Sign Out (25) 2016-09-09 22:55 43人阅读 评论(0) 收藏
1006. Sign In and Sign Out (25)
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;
struct node
{
char name[100];
int h1, h2, m1, m2, s1, s2;
}person[10000];
bool compare(int h1,int m1,int s1,int h2,int m2,int s2)
{
if (h1 < h2)
return 1;
if (h1>h2)
return 0;
if (m1 < m2)
return 1;
if (m1>m2)
return 0;
if (s1 < s2)
return 1;
if (s1>s2)
return 0;
return 0;
}
int main()
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%s %d:%d:%d %d:%d:%d", &person[i].name, &person[i].h1, &person[i].m1, &person[i].s1, &person[i].h2, &person[i].m2, &person[i].s2);
int flag1 = 0;
int flag2=0;
for (int i = 0; i < n; i++)
{
if (compare(person[i].h1, person[i].m1, person[i].s1, person[flag1].h1, person[flag1].m1, person[flag1].s1))
{
flag1 = i;
}
if (!compare(person[i].h2, person[i].m2, person[i].s2, person[flag2].h2, person[flag2].m2, person[flag2].s2))
{
flag2 = i;
}
}
printf("%s %s\n", person[flag1].name, person[flag2].name);
return 0;
}
PAT甲 1006. Sign In and Sign Out (25) 2016-09-09 22:55 43人阅读 评论(0) 收藏的更多相关文章
- PAT甲 1007. Maximum Subsequence Sum (25) 2016-09-09 22:56 41人阅读 评论(0) 收藏
1007. Maximum Subsequence Sum (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Y ...
- PAT 甲 1005. Spell It Right (20) 2016-09-09 22:53 42人阅读 评论(0) 收藏
1005. Spell It Right (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given ...
- PAT甲 1002. A+B for Polynomials (25) 2016-09-09 22:50 64人阅读 评论(0) 收藏
1002. A+B for Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue T ...
- PAT甲 1046. Shortest Distance (20) 2016-09-09 23:17 22人阅读 评论(0) 收藏
1046. Shortest Distance (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The ...
- PAT甲 1048. Find Coins (25) 2016-09-09 23:15 29人阅读 评论(0) 收藏
1048. Find Coins (25) 时间限制 50 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Eva loves t ...
- PAT甲 1041. Be Unique (20) 2016-09-09 23:14 33人阅读 评论(0) 收藏
1041. Be Unique (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Being uniqu ...
- PAT甲 1032. Sharing (25) 2016-09-09 23:13 27人阅读 评论(0) 收藏
1032. Sharing (25) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To store Engl ...
- PAT甲 1029. Median (25) 2016-09-09 23:11 27人阅读 评论(0) 收藏
1029. Median (25) 时间限制 1000 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given an incr ...
- PAT甲 1012. The Best Rank (25) 2016-09-09 23:09 28人阅读 评论(0) 收藏
1012. The Best Rank (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To eval ...
随机推荐
- MySql PartionBy
SELECT tableOld.*, if(@channelName = tableOld.channelName, @rank := @rank + 1, @rank := 1) AS rank, ...
- 基元线程同步构造之信号量(Semaphore)
信号量(semaphore)不过是由内核维护的 int32变量而已,(说通俗点就是好比一个线程容器里面允许执行的线程数,0计数就是允许执行的0个线程数,1就是允许执行的1个线程数,2就是允许执行的2个 ...
- fm 讲解加代码
转自: 博客 http://blog.csdn.net/google19890102/article/details/45532745/ github https://github.com/zhaoz ...
- 根据条件决定是否为input设置只读属性
代码如下: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <tit ...
- Zookeeper—学习笔记(一)
1.Zookeeper基本功能 (增 删 改 查:注册,监听) 两点: 1.放数据(少量). 2.监听节点. 注意: Zookeeper中的数据不同于数据库中的数据,没有表,没有记录,没有字段: Z ...
- EasyUI 列表展示及基本格式
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...
- JDK-8不是有效的Win32应用程序
- 罗马数字转整数 · Roman to Integer
13. Roman to Integer [抄题]: [暴力解法]: 时间分析: 空间分析: [思维问题]: 没有想到罗马字是逆序的情况 没有想到要先用toCharArray()方法把字符串拆成一个字 ...
- win 下 nginx 与 php的配置
1.下载需要的软件包 php的windows版本(*注意这里下载非线程安全的,nginx使用的是cgi) http://windows.php.net/download/ nginx的window ...
- 【SQL模板】二.创建表视图模板TSQL
---Name: 创建表视图模板.sql ---Purpose: 用于创建 数据库中 新的数据表/视图 ---Author: xx ---Time: 2015-12-18 10:26:06 ---Re ...