problem

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

  • 给出n个人的id和登录登出时间
  • 求最早进来和最早出去的人的ID

solution

  • 将时间都转为总秒数,输入的时候更新即可
#include<iostream>
#include<string>
using namespace std;
int main(){int n;  cin>>n;int zaojin=9999999,zaochu=0;string jin, chu;for(int i = 1; i <= n; i++){string s; cin>>s;int h1, m1, s1, h2, m2, s2;scanf("%d:%d:%d",&h1,&m1,&s1);scanf("%d:%d:%d",&h2,&m2,&s2);int t1 = h1*3600+m1*60+s1;int t2 = h2*3600+m2*60+s2;if(t1<zaojin){zaojin = t1;jin = s;}if(t2>zaochu){zaochu = t2;chu = s;}}cout<<jin<<" "<<chu;return 0;
}

【PAT甲】1006 Sign In and Sign Out (25分)循环模拟相关推荐

  1. PAT(乙级)1006 换个格式输出整数 (15 分) (C语言)

    让我们用字母 B 来表示"百".字母 S 表示"十",用 12-n 来表示不为零的个位数字 n(<10),换个格式来输出任一个不超过 3 位的正整数.例如 ...

  2. 【PAT (Advanced Level) Practice】1051 Pop Sequence (25 分)

    1051 Pop Sequence (25 分) Given a stack which can keep M numbers at most. Push N numbers in the order ...

  3. 【PAT (Advanced Level) Practice】1037 Magic Coupon (25 分)

    题意: 给出两个集合,从这两个集合里面选出数量相同的元素进行一对一相乘,求能够得到的最大乘积之和. 题解: 对每个集合,将正数和负数分开考虑,将每个集合里的整数从大到小排序:将每个集合里的负数从小到大 ...

  4. 【PAT乙级】1005 继续(3n+1)猜想 (25 分)

    https://pintia.cn/problem-sets/994805260223102976/problems/994805320306507776 题目给的意思就是说:如果这个数不能被其它数通 ...

  5. 【PAT甲级 BigInteger运算】1024 Palindromic Number (25 分) Java 全部AC

    题目 题解 Java 一开始用C++写的,有两个大数的测试点过不去,后来改用Java的BigInteger开挂,全部通过 import java.io.BufferedReader; import j ...

  6. 【PAT甲级 排序】1012 The Best Rank (25 分) C++ 全部AC

    题目 中规中矩的一道题.排名的顺序一开始没太明白,但是理解之后写起来挺流畅的,没什么坑. 解题思路:题目会给出所有学生所有科目的成绩.想要看分学生的学号. 我们要先给这些学生单科成绩排序,算出它们的单 ...

  7. 【PAT甲级 排序】1036 Boys vs Girls (25 分) C++

    题目 是个水题,排序就完事. 输出女生最高分的学生,男生最低分的学生,并计算分差. 一点点小坑:让输出啥,看清楚再写,不要靠记忆做题 一开始把题目中要求输出的NA看成了NAN,一开始有两个测试用例过不 ...

  8. PAT甲级 -- 1079 Total Sales of Supply Chain (25 分)

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

  9. PAT甲级 -- 1090 Highest Price in Supply Chain (25 分)

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

最新文章

  1. python学习之pip常用命令
  2. RNN,LSTM,GRU简单图解:
  3. (转)Java atomic原子类的使用方法和原理(一)
  4. bat产品经理能力模型_浅析产品经理能力模型
  5. OpenShift 4 之 GitOps(3)用Helm+ArgoCD部署应用,并保持配置同步
  6. [LibreOJ β Round #4] 子集
  7. spring boot (整合redis)
  8. 干货 | 百亿节点,毫秒级延迟,携程金融基于nebula的大规模图应用实践
  9. c语言入门自学课件ppt,C语言入门教程ppt(434页)免费版[精品课件]
  10. 实验二 (一) 大小写英文字母表
  11. zblog微信小程序模板-青春主题小程序免费开源模板
  12. AI基础-NLP概览-极速入门
  13. 多多自走棋改动_多多自走棋:官方更新久久未到,新版本内容或将引起巨大改变...
  14. jquery 模拟点击事件
  15. python求梅森尼数_python3算梅森素数的最佳代码是什么?
  16. (小白都能听懂)的海明校验码
  17. 转:成功学专家卡耐基所言
  18. 映客2020年报:转型的主动与被动
  19. 达特茅斯计算机专业师资力量如何,达特茅斯学院本科计算机专业怎么样?
  20. 使用Ceph作为OpenStack的统一存储解决方案

热门文章

  1. 切片 go 去除第一个_golang学习笔记--切片slice 与数组 arr
  2. php ajax设置cookie,在AJAX请求中设置Cookie?
  3. java个人博客系统源码_Java基于SSM的个人博客系统(源码 包含前后台)
  4. 七月在线python数据分析_七月在线Python数据分析笔记
  5. python简单爬虫代码-使用Python3.5写简单网络爬虫
  6. 学python可以做什么-学Python语言可以做什么?
  7. python编程是啥-python中type()是什么意思
  8. 为什么李开复说科大讯飞不懂语音,99%的语音识别项目要死掉?
  9. 语言密码加密变星号_为什么汉字不能设成密码,你想过吗?
  10. echarts折线图y轴根据数值自动_R语言基础绘图教程——第3章:折线图和带状图...