PAT甲级——1006 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的更多相关文章
- 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 ...
- PAT 甲级 1006 Sign In and Sign Out
https://pintia.cn/problem-sets/994805342720868352/problems/994805516654460928 At the beginning of ev ...
- PAT甲级1006水题飘过
题目分析:由于不存在相同的两个时间(24:00:00和00:00:00不会同时存在),则我们假设两个全局变量存放到达的最早的时间和达到的最晚的时间,设置最早的初值为“23:59:59”,设置最晚的初值 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- Codeforces 1291A - Even But Not Even
题目大意: 给定一个字符串数字(很大) 问能不能删除一些数字(或者不删除) 使得剩余的数字各位数相加是偶数,但是这整个数字是个奇数 解题思路: 统计字符串中单个数字奇数的个数 分情况 个数为0或者1时 ...
- POJ 1149:PIGS 网络流经典题
PIGS Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 18345 Accepted: 8354 Description ...
- Arduino Wireless Communication – NRF24L01 Tutorial(arduino无线通信---NRF24L01教程)
arduino下nrf24l01库文件及相关说明 库的说明文档 https://tmrh20.github.io/RF24/ 库的源代码github下载页面 https://tmrh20.github ...
- Bugku 社工
1.密码 姓名:张三 生日:19970315 猜想KEY是:zs19970315. 结果就是如此.
- gradle配置多个代码仓库repositories
repositories { mavenCentral() maven { url "https://jitpack.io" } maven { url "http:// ...
- 18 11 04 初用单片机 c语言学习
---恢复内容开始--- 1 作为单片机使用的的 c 语言学习 ++ 增位运算符 在原有基础上加一 -- 相同 由于单片机只有 ~ 取反 & 两个 参数里有没有 | 两个 参数里有没有 ^ 两 ...
- 客户主题分析(tableau)—客户分群
主要分析方面:客户合理分群 客户分群实现:使用聚类构建指标,需理解聚类的分析逻辑,需使用软件:tableau 聚类方法:选择3指标分别为购买总金额,客户购买次数.类平均购买价格(四类的平均购买价格,四 ...
- 小结spring给项目开发的好处
1.spring 抽象了许多开发中遇到的共性问题:支持pojo和javaBean开发使应用面向接口开发.如各种Template 2.Ioc 容器使得对象间的耦合关系文本化.外部化,即通过xml的配置就 ...
- 91.一次性处理多条数据的方法:bulk_create,update,delete
(1)bulk_create: 可以一次性的创建多个对象 示例代码如下: from django.http import HttpResponse from .models import Pulish ...
- vscode显示当前文件完整路径信息
Code->Preferences->Settings 搜索window.title 原本是activeEditorShort,修改 activeEditorShort => act ...