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的更多相关文章

  1. 浙江大学 pat 1006题解

    1006. Sign In and Sign Out (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...

  2. PAT 1006 换个格式输出整数 (15)(C++&JAVA&Python)

    1006 换个格式输出整数 (15)(15 分) 让我们用字母B来表示"百".字母S表示"十",用"12...n"来表示个位数字n(& ...

  3. PAT——1006. 换个格式输出整数

    1006. 换个格式输出整数 (15) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 让我们用字母B来表示“百” ...

  4. 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 ...

  5. PAT 1006. 换个格式输出整数 (15)

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

  6. 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, ...

  7. PAT 1006. Sign In and Sign Out

    #include<iostream> #include<string> using namespace std; int main(){ int cnt;cin>> ...

  8. PAT 1006 换个格式输出整数

    https://pintia.cn/problem-sets/994805260223102976/problems/994805318855278592 让我们用字母B来表示“百”.字母S表示“十” ...

  9. PAT 1006 换个格式输出 C语言

    让我们用字母B来表示“百”.字母S表示“十”,用“12...n”来表示个位数字n(<10),换个格式来输出任一个不超过3位的正整数.例如234应该被输出为BBSSS1234,因为它有2个“百”. ...

随机推荐

  1. POJ 3648 Wedding (2-SAT,经典)

    题意:新郎和新娘结婚,来了n-1对夫妻,这些夫妻包括新郎之间有通奸关系(包括男女,男男,女女),我们的目地是为了满足新娘,新娘对面不能坐着一对夫妻,也不能坐着有任何通奸关系的人,另外新郎一定要坐新娘对 ...

  2. Java 7 Fork/Join 并行计算框架概览

    应用程序并行计算遇到的问题 当硬件处理能力不能按摩尔定律垂直发展的时候,选择了水平发展.多核处理器已广泛应用,未来处理器的核心数将进一步发布,甚至达到上百上千的数量.而现在 很多的应用程序在运行在多核 ...

  3. (转)MySQL数据库引擎ISAM MyISAM HEAP InnoDB的区别

    转自:http://blog.csdn.net/nightelve/article/details/16895917 MySQL数据库引擎取决于MySQL在安装的时候是如何被编译的.要添加一个新的引擎 ...

  4. 学习面试题Day05

    1.如何理解数组在Java中作为一个类? Java的数组本质上是一个类,该类还保存了数据类型的信息.该类通过成员变量的形式来保存数据,并且通过[]符号,使用下标来访问这些数据.在处理基本类型数据时,数 ...

  5. 研究一家公司 z

    第一部分:确定一家公司的“质地”(描绘一家公司的总体印象)              1.1 天花板       天花板是指企业或行业的产品(或服务)趋于饱和.达到或接近供大于求的状态.在进行投资之前 ...

  6. HDU 2196-Computer(树形dp)

    题意: 给出电脑网络连接树,求每个节点的为起点的最长距离 分析: 这道题开始状态想不出来,放了一段时间,后来注意到例题上有这道题,每个节点的最长距离可由父节点的最长距离,次长距离,和子节点的最长距离( ...

  7. js 中&& 与 ||

    /*** 几乎所有语言中||和&&都遵循“短路”原理,* 如&&中第一个表达式为假就不会去处理第二个表达式,而||正好相反.* js也遵循上述原则.* 当||时,找到为 ...

  8. Android下NFC的简单使用

    现在很多手机已经配备了NFC(Near Field Communication 近场通信)的功能,我就为此专门研究过,可以到本文末尾下载源代码. Android官方资料:http://develope ...

  9. Arrays.asList的源码分析

    以前一直很奇怪为什么Arrays.asList的数组不能插入新的数据,后来看了源码发现是因为内部是一个final的数组支持起来的Arraylist,下面贴入源码与分析. 1.先看Arrays的方法 我 ...

  10. OpenCV入门学习笔记

    OpenCV入门学习笔记 参照OpenCV中文论坛相关文档(http://www.opencv.org.cn/) 一.简介 OpenCV(Open Source Computer Vision),开源 ...