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. 面向对象变成(OOP)-创建类和使用类

    1.1.1对象的抽象:抽象是一种归纳或总结,对象是现实世界物体特征的实例. (1)一切皆是对象. (2)类是对象的抽象. 1.1.2 对象的使用: 当对象被抽象为类以后,就可以创建具体的实例来操作了. ...

  2. Mybatis框架的简单配置

    Mybatis 的配置 1.创建项目(当然,这是废话) 2.导包 下载mybatis-3.2.0版:https://repo1.maven.org/maven2/org/mybatis/mybatis ...

  3. Causal Corpus 事件因果关系语料统计

    Causal Corpus 事件因果关系语料统计 本文是对因果关系抽取领域数据库标注及开源情况的统计.除了对因果关系的标注,一些类似的语料也包含在内,从而为语料的使用提供灵活性,可以根据不同的目标选取 ...

  4. 刷题46. Permutations

    一.题目说明 题目是46. Permutations,给一组各不相同的数,求其所有的排列组合.难度是Medium 二.我的解答 这个题目,前面遇到过类似的.回溯法(树的深度优先算法),或者根据如下求解 ...

  5. 【数据结构】单链表介绍及leetcode206题反转单链表python实现

    题目传送门:https://leetcode-cn.com/problems/reverse-linked-list/ 文章目录 单链表介绍 链表 概念 种类 优缺点 单链表(slist) leetc ...

  6. Android如何用一个TextView显示不同颜色得字符

    最近做一个项目,需要一个字符串显示不同的颜色.当时直接想到的就是用多个TextView来拼接,但是如果字符数量多的话,这样写是非常麻烦得.而且还要增加很多控件. 后来发现一个非常方便得方法.直接看代码 ...

  7. 给adobe acrobat reader 添加图片注释

    首先展示一下  我添加注释的结果, 下面是我的做法: 在Adobe Acrobat 中打开Sample.pdf文档,点开文档右边的“工具”-“内容”-选择“编辑对象”,鼠标光标变成实心箭头+右下角小方 ...

  8. Microsoft SQL Server Management Studio连接后报“ viewInfo (Microsoft.SqlServer.Management.SqlStudio.Expl”

    解决办法: 在路径:C:\Users\你的用户名\AppData\Local\Temp\”新建文件夹并命名为2,如果已经有 2 则看清楚是否是文件而不是文件夹,删掉文件改为文件夹: 如果是找不到\Us ...

  9. windows下MariaDB忘记密码找回

    1.首先停止数据库 2.找到my.ini文件 3.右键以记事本打开在Mysqld下添加如下一行保存,然后启动数据库 4.登录数据库会提示输入密码,默认回车即可 5.退出数据库,删除我们上面在my.in ...

  10. svg用例

    圆<circle cx="x" cy="y" r="r" style="stroke:black;fill:none&quo ...