1006. Sign In and Sign Out (25)

时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

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) 收藏的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. Haddop SHUTDOWN_MSG: Shutting down NameNode at java.net.UnknownHostException: process01: process01: unknown error

    SHUTDOWN_MSG: Shutting down NameNode at java.net.UnknownHostException: process01: process01: unknown ...

  2. Realm For Android详细教程

    目录 1.Realm简介 2.环境配置 3.在Application中初始化Realm 4.创建实体 5.增删改查 6.异步操作 7.Demo地址(https://github.com/RaphetS ...

  3. The Unique MST

    The Unique MST http://poj.org/problem?id=1679 Time Limit: 1000MS   Memory Limit: 10000K Total Submis ...

  4. ios 打tag

    修改spec文件的version: git commit -am"version 0.1.1" git push origin master -u git tag 0.1.1 gi ...

  5. pdf转word在线转换器

    昨天大学辅导员联系我让我pdf转word,一番搜索终于找到一款免费好用的在线转换器,亲测好使免费

  6. [leetcode]403. Frog Jump青蛙过河

    A frog is crossing a river. The river is divided into x units and at each unit there may or may not ...

  7. CentOS 7安装zabbix步骤

    Zabbix配置安装 1.前期准备: 我自己的基础环境:CentOS 7 + Mysql 5.6 可以根据官网介绍一步一步安装,官网地址:https://www.zabbix.com/ 图1: 然后点 ...

  8. oracle基本查询入门(一)

    一.基本select语句 SELECT *|{[DISTINCT] column|expression [alias], ...} FROM table; 例如: --查询所有数据 select * ...

  9. win10下安装oracle11G Examples出错[INS-32025][INS-52001]

    安装oracle examples时提示出错:[INS-32025] 所选安装与指定 Oracle 主目录中已安装的软件冲突.[INS-52001] Oracle Database Examples ...

  10. Developing ADF PageTemplates

    Developing ADF PageTemplates In this hands-on, you learn how to create a page template and use this ...