PAT1006:Sign In and Sign Out
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 思路
很简单,找到最小登入时间的id和最大登出时间的id输出即可。时间直接转换成int型比较大小。 代码
#include<iostream>
#include<vector>
using namespace std;
int main()
{
int N;
while(cin >> N)
{
vector<string> id(N);
string signin,signout;
int minsignin = ,maxsignout = -;
int minIndex = ,maxIndex = ;
for(int i = ; i < N;i++)
{
cin>>id[i] >> signin >> signout;
int intime = stoi(signin.erase(,).erase(,));
int outtime = stoi(signout.erase(,).erase(,));
if(intime < minsignin)
{
minIndex = i;
minsignin = intime;
} if(outtime > maxsignout)
{
maxIndex = i;
maxsignout = outtime;
}
}
cout << id[minIndex] << " " << id[maxIndex] << endl;
}
}
PAT1006:Sign In and Sign Out的更多相关文章
- pat1006. Sign In and Sign Out (25)
1006. Sign In and Sign Out (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...
- 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 ...
- PTA (Advanced Level) 1006 Sign In and Sign Out
Sign In and Sign Out At the beginning of every day, the first person who signs in the computer room ...
- 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 ...
- 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 ...
- 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(25 分)
1006 Sign In and Sign Out(25 分) At the beginning of every day, the first person who signs in the com ...
- PAT甲级——1006 Sign In and Sign Out
PATA1006 Sign In and Sign Out At the beginning of every day, the first person who signs in the compu ...
随机推荐
- Makefile学习(三)[第二版]
make常用内嵌函数 1.函数调用 $(function arguments) #$引用的结果就是函数生成的结果 2.Makefile下常用的函数 1)$(wildcard PATTERN) #匹配当 ...
- GRUB与Linux系统修复(第二版)
GRUB配置解析 配置文件保存在 /boot/grub/grub.conf[/boot分区最好应该单独划分出来] 软链接保存在 /etc/grub.conf 1.grub.conf文件分析 defau ...
- 【面试笔试算法】Problem 8: 然而沼跃鱼早就看穿了一切(hiho题库)
时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 fjxmlhx每天都在被沼跃鱼刷屏,因此他急切的找到了你希望你写一个程序屏蔽所有句子中的沼跃鱼("marshtom ...
- Slop One 算法
Slope One 算法是由 Daniel Lemire 教授在 2005 年提出的一个 Item-Based 推荐算法. Slope One 算法试图同时满足这样的的 5 个目标: 易于实现和维护: ...
- EBS R12安装升级(FRESH)(三)
5 EBS R12.1.1安装后配置 5.1 新建patch文件夹 1 2 3 su - root mkdir /stage/patch chmod 777 /stage/patch 打补丁说明:随便 ...
- LeetCode之旅(19)-Power of Two
题目 Given an integer, write a function to determine if it is a power of two. Credits: Special thanks ...
- obj-c编程12:复制对象
好吧,上一篇我怎么也没想到会写那么多字那么少的代码,希望这一篇不会如此哦. 言归正传,对象的复制分为浅复制和深复制,前者只是复制对象的引用,当原对象的内容发生变化时,复制对象的内容也会发生变化,毕竟他 ...
- GNU中的处理目标文件的若干工具
AR 创建静态库,插入.删除.列出和提取成员: SRING 列出目标文件中的字符串: SIRIP 从目标文件中删除符号表信息: NM 列出目标文件符号表中定义的符号: SIZE 列出目标文件中节的名字 ...
- LeetCode - 二叉树的最大深度
自己解法,欢迎拍砖 给定一个二叉树,找出其最大深度. 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数. 说明: 叶子节点是指没有子节点的节点. 示例:给定二叉树 [3,9,20,null,nu ...
- VS 和 VAssistX 常用快捷键
----------------------------------------------------------------函数跳转-------------------------------- ...