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. html的视频插件 (转)

         1)jMedia Element是一个基于jQuery/jQuery UI实现的HTML5音频/视频开发工具包.提供非常多的功能来控制页面中的音频和视频内容.当旧的浏览器不兼容HTML5时, ...

  2. 关于Memcache mutex设计模式的.net实现

    之前在网上看过memcache-mutex的场景分析和实现代码,这里将.net方式加以实现,当然这里主要是依据原文的伪代码照猫画虎,以此做为总结及记录.如果您对相应实现感兴趣可以尝试使用本文提供的代码 ...

  3. selenium在chrome上运行报 Element is not clickable at point (1096, 26)

    Firefox上正常运行的脚本在chrome上提示Element is not clickable at point (1096, 26).分析原因,首先肯定不是因为页面元素不存在而无法点击.也不是要 ...

  4. 转:maven项目添加jar包.

    很多新手都不知道如何在maven项目里添加jar包. 以前我还没接触maven的时候下载过一个demo,是maven项目. 我居然是照着他的pom.xml文件一个一个的写!!! 很多人认为理所当然的东 ...

  5. 【原】实验室签到PHP版本

    表单 <html> <body> <h1>实验室自动签到测试</h1> <h2>输入学号和登录密码(建议自己改过密码后再来录入您的数据)&l ...

  6. git 的版本回滚

    当用git clone 复制远程代码库到本地时,使用 git branch 只能看到默认库(master),当远程库有多个分支时,可以使用 git branch -a 查看全部的分支, 然后git c ...

  7. sys.stdout 重定向

    通俗的来说,sys.stdout的功能类似与C++里面的文件输出功能fprintf. 接下来直接入正题,让我们来看代码: >>> import sys >>> te ...

  8. 【UR #12】实验室外的攻防战(BIT)

    [题目链接] http://uoj.ac/problem/180 [题意] 给定两个1..n的排列AB,只有当ai<ai+1才能交换ai和ai+1,问是否能够将A转换为B. [思路] 令a[i] ...

  9. window2008 64位系统没有office组件问题分析及解决

    服务器是windows server2008 64位系统, 我的系统需要用到Microsoft.Office.Interop.Excel组件 在上传Excel单据遇到错误:检索 COM 类工厂中 CL ...

  10. VMware 克隆虚拟机或加载新的已安装虚拟机时System eth0不能使用的解决方法

    近年来的大数据应用特别热,特别是Hadoop和Spark.但大家使用这些分布式文件系统和计算框架都需要一个分布式的集群环境,而大家手头一般没有多余的机器部署master和多个slave节点,就只能在V ...