PAT 1006
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
简单题,找到最大最小即可。
代码
1 #include <stdio.h>
2
3 int main()
4 {
5 int M;
6 char ID[][];
7 int sign_in_time[];
8 int sign_out_time[];
9 int in_h,in_min,in_sec,out_h,out_min,out_sec;
while(scanf("%d",&M) != EOF){
int i;
for(i=;i<M;++i){
scanf("%s%d:%d:%d %d:%d:%d",ID[i],&in_h,&in_min,&in_sec,&out_h,&out_min,&out_sec);
sign_in_time[i] = in_h * + in_min * + in_sec;
sign_out_time[i] = out_h * + out_min * + out_sec;
}
int in_min = sign_in_time[],in_ind = ;
int out_max = sign_out_time[],out_ind = ;
for(i=;i<M;++i){
if(sign_in_time[i] < in_min){
in_min = sign_in_time[i];
in_ind = i;
}
if(sign_out_time[i] > out_max){
out_max = sign_out_time[i];
out_ind = i;
}
}
printf("%s %s\n",ID[in_ind],ID[out_ind]);
}
return ;
}
PAT 1006的更多相关文章
- 浙江大学 pat 1006题解
1006. Sign In and Sign Out (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...
- PAT 1006 换个格式输出整数 (15)(C++&JAVA&Python)
1006 换个格式输出整数 (15)(15 分) 让我们用字母B来表示"百".字母S表示"十",用"12...n"来表示个位数字n(& ...
- PAT——1006. 换个格式输出整数
1006. 换个格式输出整数 (15) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 让我们用字母B来表示“百” ...
- 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. 换个格式输出整数 (15)
让我们用字母B来表示"百".字母S表示"十",用"12...n"来表示个位数字n(<10),换个格式来输出任一个不超过3位的正整数.例 ...
- pat 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, ...
- PAT 1006. Sign In and Sign Out
#include<iostream> #include<string> using namespace std; int main(){ int cnt;cin>> ...
- PAT 1006 换个格式输出整数
https://pintia.cn/problem-sets/994805260223102976/problems/994805318855278592 让我们用字母B来表示“百”.字母S表示“十” ...
- PAT 1006 换个格式输出 C语言
让我们用字母B来表示“百”.字母S表示“十”,用“12...n”来表示个位数字n(<10),换个格式来输出任一个不超过3位的正整数.例如234应该被输出为BBSSS1234,因为它有2个“百”. ...
随机推荐
- Java [leetcode 10] Regular Expression Matching
问题描述: Implement regular expression matching with support for '.' and '*'. '.' Matches any single cha ...
- 选择select框跳出信息
<html > <body > <select type="select" name=s1 onChange=alert("你选择了&quo ...
- Loadrunner通过sitescope监控mysql
1. Loadrunner通过sitescope监控mysql 1.1. Sitescope下载 第一次在网上下载的是sitescope11.30,安装之后无法破解,所以最后卸载了,重新下载了si ...
- FZU 2129 子序列个数
Problem Description 子序列的定义:对于一个序列a=a[1],a[2],......a[n].则非空序列a'=a[p1],a[p2]......a[pm]为a的一个子序列,其中1& ...
- mac中viso的兼容工具
http://www.orsoon.com/Mac/77738.html破解教程 http://www.pc6.com/mac/111747.html下载地址 很强大,很爽.
- python 网络编程(三)---TCP 服务器端客户端实现
客户端 客户端主要有4个步骤: 1)创建一个socket以连接服务器. socket = socket.socket(family, type),family参数代表地址家族,可为AF_INET(包括 ...
- 包含到cocos2d-x里的tcpsocket源码
声明:本文参考了langresser发布的blog“跨平台的游戏客户端Socket封装” Socket处理是异步非阻塞的,所以可以放心的放到主线程处理消息,并且在原作者的基本上进行了系列优化,考虑了客 ...
- delphi 删除目录和创建目录,临时文件夹
获取用户当前的Windows临时文件夹function GetWinTempPath: string;varTempDir: array[0..255] of char;beginGetTempPat ...
- ALM11需求和测试覆盖率图解1
覆盖率分析视图 需求覆盖率选项卡
- loadmore
实例点击 loadmore.js /* * loadmore.js require jQuery,artTemplate * Butterfly 2013.08.28 */ define(['../u ...