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 ...
随机推荐
- java编写一个汽车类,有属性:品牌、型号、排量、速度,有方法:启动、加速、转弯、刹车、息火
/* * 汽车实体类 * 类里面有属性和方法 */public class Car { String brand; //汽车品牌 String modelNumber; //汽车型号 ...
- php 随笔算法
<? //-------------------- // 基本数据结构算法 //-------------------- //二分查找(数组里查找某个元素) function bin_s ...
- linux 配置Tomcat开机启动
一台安装有tomcat的linux服务器 方法/步骤 1 请自行下载安装配置tomcat的服务器环境 本经验仅仅介绍如何配置tomcat的开机自动启动 2 切换到tomcat/bin目录下 用vi ...
- Linux 软件 安装到 /usr,/usr/local/ 还是 /opt 目录
Linux 的软件安装目录是也是有讲究的,理解这一点,在对系统管理是有益的 /usr:系统级的目录,可以理解为C:/Windows/,/usr/lib理解为C:/Windows/System32./u ...
- dubbo+springMVC+Spring+Mybatis
1.新建Maven Project 1.1 1.2 2新建Maven Module ——提供者和消费者都需要引用的共同代码块(如entity和service接口) 2.1 2.2 2.3 2. ...
- input限制数字输入
onkeyup="this.value=this.value.replace(/\D/g,'')"
- Maven项目标准目录结构
-----------------------siwuxie095 Maven 项目标准目录结构 1.Maven 项目分为两种 (1)Java 项目 (2)Web 项目 2.对于 Java 项目 其中 ...
- JSP页面中的EL表达式介绍
1.什么是EL? Expression Language(表达式语言) 2.EL的功能 替代JSP页面中数据访问时的复杂编码. 3.EL的特点 自动转换类型 使用简单 4.EL表达式的语法 ${EL ...
- webstorm 2017 激活破解
2017-06-15更新 之前都是使用2017.2.27的方法,版本是2017.1.1,还没提示过期,但是根据评论说这个链接已经失效了,评论也给出了个新地址:http://idea.iteblog.c ...
- Windows10电脑安装macOS Mojave系统的方法(最新版系统,含超详细步骤截图)
一.环境及准备工作 1.主机系统:本人系统是Windows10家庭中文版 2.虚拟机软件:VMware Workstation 14 Pro 虚拟机版本号:14.1.1 build-7528167 虚 ...