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. android广告平台介绍

    广告模式:   广告条:最普遍的广告模式,嵌入在应用界面内,用户点击行为会带来收入.   积分墙:应用通过限制功能.去广告等引导用户进入积分墙页面下载广告应用得到积分来换取使用的模式,用户安装完推荐广 ...

  2. 【Tcpcopy】离线回放功能

    最近因调试问题,需要一直进行tcpcopy,拿有问题的包进行测试.决定使用tcpcopy对录制脚本进行回放,以下为我操作的具体步骤.主要是三块 1 下载安装具有离线回放功能的tcpcopy 2 使用t ...

  3. [转]VPN服务器配置详解

    借助VPN,企业外出人员可随时连到企业的VPN服务器,进而连接到企业内部网络.借助windows2003的“路由和远程访问”服务,可以实现基于软件的VPN. VPN(Virtual Private N ...

  4. [King.yue]Ext.net 页面布局Flex

    此属性仅当父布局HboxLayout或使用VboxLayout.此配置选项被应用到子项目容器管理的布局.每个子项目以Flex属性被弯曲的水平根据每个项目的相对弹性值比较,都带有一个弯曲值指定项目金额. ...

  5. iOS7程序后台运行

    介绍 这次 iOS7 对程序后台运行进行了加强,但是仅仅是加强而已,要想像 Android 程序那样自由当然就别想了,苹果这么做主要还是出于电池使用时间考虑,但是这次的加强对大部分程序基本够用. 在介 ...

  6. 【原】Redis分区

    Redis高级篇 分区 为什么分区? Redis中的分区主要有两个目的: 允许用多台机器的内存存放更大的数据集.如果没有分区,那么你只能存放单台机器内存的最大值的数据集. 允许用多核和多台机器提高计算 ...

  7. CRC(Cyclic Redundancy Check)循环冗余校验码与海明码的计算题

    (17)采用CRC进行差错校验,生成多项式为G(X)=X4+X+1,信息码字为10111,则计算出的CRC校验码是  (17)  .A.0000  B.0100   C.0010   D.1100试题 ...

  8. ASP.NET_验证控件(class0620)

    为什么使用验证控件 当需要让用户输入数据时,用户有可能输入不符合我们程序逻辑要求的信息,所以我们要对输入进行验证. 客户端验证(用户体验,减少服务器端压力) 服务器端验证(防止恶意攻击,客户端js很容 ...

  9. VS2010手动添加外部工具和快捷键

    一.添加外部工具 1.选择工具->外部工具 2.选择添加,然后填相应的程序路径和传给程序的参数. 标题:所创建的工具名字 命令:工具路径 参数:工具命令行参数 初始目录:工具工作目录,有些工具可 ...

  10. hive 中出现struct 结构化的问题

    如果你使用udf,udaf,udtf中的某一个并且查询日志中出现如下之类的struct错误 java.lang.RuntimeException: Error in configuring objec ...