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个“百”. ...
随机推荐
- Google Gson解析Json数据应用实例
转自:http://lixigao449778967.blog.163.com/blog/static/24985164201269105928783/ 1.需要的Jar包 1) Google Gso ...
- Codeforces 611D New Year and Ancient Prophecy dp+字符串比较
这是CF Goodbye 2015 的D题,当时我想了一个n^3的dp算法,肯定不能过,然后听到学长后缀数组的n^2log(n)写法,仰慕 最后打完比赛看到了t神的n^2写法,简直膜拜,直接省去了后缀 ...
- Zabbix探索:工作时间的设置
默认情况下,Zabbix的工作时间是启用的. 启用后,图形的北京在工作时间内就是白底的,否则就是灰底的. 今天纠结了半天,因为无论如何都是灰底的. 后来连接到服务器上一看,靠,忘记同步时间了,所以刚好 ...
- NOIP2011 计算系数
1计算系数 给定一个多项式 (ax + by)k ,请求出多项式展开后 x n y m 项的系数. [输入] 输入文件名为 factor.in. 共一行,包含 5 个整数,分别为 a,b,k,n,m, ...
- 【翻译】运行于x86机器上的FreeBSD的PCI中断
来源 http://people.freebsd.org/~jhb/papers/bsdcan/2007/article/article.html 摘要 在拥有多个独立设备的计算机里一个重要的元素是一 ...
- Cppcheck代码分析(2)
功能 解析函数中的可能的代码执行流 函数实际执行中只会执行代码流中的一条流 分析: 分支语句 if-else ,switch-case 循环语句 while, do-while ,for 代码流举例 ...
- Solution for latex error:”Unknown graphics extension: .eps“ or "Can not find XXX"
Sample code: \begin{figure*} \centering % Requires \usepackage{graphicx} \includegraphics[width=7in] ...
- BNUOJ-26580 Software Bugs KMP匹配,维护
题目链接:http://www.bnuoj.com/bnuoj/problem_show.php?pid=26580 题意:给一个模式串,然后m个匹配串,要求删掉匹配串中的所有存在的模式串,使得余下的 ...
- android 链接蓝牙不稳定的解决建议
My workaround I scan BLE for a short period of time 3-4 seconds then I turn scan OFF for 3-4 seconds ...
- Java中使用ThreadPoolExecutor并行执行独立的单线程任务
Java SE 5.0中引入了任务执行框架,这是简化多线程程序设计开发的一大进步.使用这个框架可以方便地管理任务:管理任务的生命周期以及执行策略. 在这篇文章中,我们通过一个简单的例子来展现这个框架所 ...