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个“百”. ...
随机推荐
- 【转】FragmentTest学习笔记1
原文网址:http://blog.csdn.net/hishentan/article/details/20734489 源码部分: BookContent.java package com.exam ...
- NopCommerce架构分析之三---数据库初试化及数据操作
系统启动时执行任务:IStartupTask,启动时执行的任务主要是数据库的初始化和加载. IStartupTask调用IEfDataProvider进行数据库的初始化. IEfDataProvide ...
- memcached单点故障与负载均衡
在上文中,主要教大家如何搭建在windows IIS 7.5下搭建php环境,使用常见的两种memcached性能监视工具.通过自己动手实践,观察监控工具上数据,相信大家对于memcached的了解 ...
- Month Calendar
http://www.codeproject.com/Articles/10840/Another-Month-Calendar#xx4614180xx Another Month Calendar ...
- C# 多线程 方法,类的标记
[MethodImplAttribute(MethodImplOptions.Synchronized)] 此标记可用于方法,将一个方法标记为单线程进入,但在多个实例的时候仍有可能导致问题,比较有共享 ...
- POJ 3321 Apple Tree(dfs序树状数组)
http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=10486 题意:一颗有n个分支的苹果树,根为1,每个分支只有一个苹果,给出n- ...
- n & (n-1)
n&(n-1)作用:将n的二进制表示中的最低位为1的改为0,先看一个简单的例子: n = 10100(二进制),则(n-1) = 10011 ==>n&(n-1) = 10000 ...
- nyoj 14 会场安排问题
会场安排问题 时间限制:3000 ms | 内存限制:65535 KB 难度:4 描述 学校的小礼堂每天都会有许多活动,有时间这些活动的计划时间会发生冲突,需要选择出一些活动进行举办.小刘的工 ...
- [POLITICS] S Korea lawmakers vote to impeach leader
South Korea's Parliament has voted to impeach President Park Geun-hye. The National Assembly motion ...
- 【Away3D代码解读】(一):主要类及说明
在深入解读Away3D的代码之前,需要对其有个大概的认识.本节主要列出Away3D中常用的类,并附上说明: View3D: Away3D的入口类,即创建该类就会初始化一个可以使用GPU呈现3D的对象, ...