PATA1006 Sign In and Sign Out

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<cstdio>
#include<iostream>
using namespace std;
struct pNode{
	char ID[20];
	int hh;
	int mm;
	int ss;
} temp,ans1,ans2;

bool compare(pNode node1,pNode node2)
{
	if(node1.hh!=node2.hh) return node1.hh>node2.hh;
	if(node1.mm!=node2.mm) return node1.mm>node2.mm;
	return node1.ss>node2.ss;
}

int main()
{
	ans1.hh=23;
	ans1.mm=59;
	ans1.ss=59;
	ans2.hh=00;
	ans2.mm=00;
	ans2.ss=00;
	int N;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		scanf("%s %d:%d:%d",temp.ID,&temp.hh,&temp.mm,&temp.ss);
		if(compare(temp,ans1)==false)
		{
			ans1 = temp;
		}
		scanf("%d:%d:%d",&temp.hh,&temp.mm,&temp.ss);
		if(compare(temp,ans2)==true)
		{
			ans2 = temp;
		}

	}

	printf("%s %s\n",ans1.ID,ans2.ID);
	return 0;
}

PAT甲级——1006 Sign In and Sign Out的更多相关文章

  1. PAT 甲级 1006 Sign In and Sign Out (25)(25 分)

    1006 Sign In and Sign Out (25)(25 分) At the beginning of every day, the first person who signs in th ...

  2. PAT 甲级 1006 Sign In and Sign Out

    https://pintia.cn/problem-sets/994805342720868352/problems/994805516654460928 At the beginning of ev ...

  3. PAT甲级1006水题飘过

    题目分析:由于不存在相同的两个时间(24:00:00和00:00:00不会同时存在),则我们假设两个全局变量存放到达的最早的时间和达到的最晚的时间,设置最早的初值为“23:59:59”,设置最晚的初值 ...

  4. PAT (Advanced Level) Practice 1006 Sign In and Sign Out (25 分) 凌宸1642

    PAT (Advanced Level) Practice 1006 Sign In and Sign Out (25 分) 凌宸1642 题目描述: At the beginning of ever ...

  5. PAT甲 1006. Sign In and Sign Out (25) 2016-09-09 22:55 43人阅读 评论(0) 收藏

    1006. Sign In and Sign Out (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...

  6. pat 1006 Sign In and Sign Out(25 分)

    1006 Sign In and Sign Out(25 分) At the beginning of every day, the first person who signs in the com ...

  7. PAT Sign In and Sign Out[非常简单]

    1006 Sign In and Sign Out (25)(25 分) At the beginning of every day, the first person who signs in th ...

  8. 1006 Sign In and Sign Out (25 分)

    1006 Sign In and Sign Out (25 分) At the beginning of every day, the first person who signs in the co ...

  9. 1006 Sign In and Sign Out (25)(25 分)思路:普通的时间比较题。。。

    1006 Sign In and Sign Out (25)(25 分) At the beginning of every day, the first person who signs in th ...

随机推荐

  1. maven常用配置setting.xml详解

    参考文章: https://www.cnblogs.com/hwaggLee/p/4579418.html 1.<localRepository/> 该值maven本地仓库的路径 < ...

  2. Python小数据池

    一. id is == 二. 代码块 三. 小数据池 四. 总结 一,id,is,== 在Python中,id是什么?id是内存地址,那就有人问了,什么是内存地址呢? 你只要创建一个数据(对象)那么都 ...

  3. ubuntu 18.04 安装 Redis-server

    Redis 安装 Redis是一款内存键值存储,以其灵活性,性能和广泛的语言支持而闻名.本教程将演示如何在Ubuntu 18.04服务器上安装和配置Redis.主要内容包括: 安装 Redis Red ...

  4. UVA 11404 简单LCS模型DP 字典序比较

    这个题目求某个字符串中含的最长的回文子串. 就是一个很简单的LCS模型吗,而且我不明白为什么网上这么多人都说仿照某写法把字符串先逆序一下,然后求LCS,我只想问一下,有必要吗? 直接按LCS的套路来就 ...

  5. xdc如何设置输入延时

    常用命令: Set_input_delay,create_clock,set_output_delay以及用于组合逻辑的set_max_delay. Input delay: 什么是输入延时? Tra ...

  6. Necroptosis|Apoptosis|CTC|

    大数据-外周血研究 Necroptosis与Apoptosis...区别:肿瘤导致和自身凋亡. CTC,肿瘤细胞脱落进入外周血,CTC(循环肿瘤细胞,CirculatingTumorCell)是存在于 ...

  7. C#——发送邮件

    需要2个引用 using System.Net;using System.Net.Mail; using (MailMessage mailMessige=new MailMessage()) usi ...

  8. 关于 SQL Server 数据库批量备份与还原的一些 Tips

    一.前提 最近需要将服务器 A 上的数据库全部备份,并在服务器 B 上进行还原,30多个数据库一个一个地用鼠标点,先是 backup,之后时 restore……整个过程实在是太浪费时间了!于是直接写一 ...

  9. 2. react 编程实践 俄罗斯方块-环境搭建

    1. 创建 demo 目录 mkdir demo 2. 初始化应用 npm init 工程信息 package name : tetris-class-demo version: descriptio ...

  10. linux.linuxidc.com - /2011年资料/Android入门教程/

    本文转自 http://itindex.net/detail/15843-linux.linuxidc.com-%E8%B5%84%E6%96%99-android Shared by Yuan 用户 ...