zoukankan      html  css  js  c++  java
  • 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 <bits/stdc++.h>
     2 using namespace std;
     3 typedef long long ll;
     4 inline ll read(){
     5     int x=0,f=1;char ch=getchar();
     6     while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
     7     while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
     8     return x*f;
     9 }
    10 
    11 /***********************************************************/
    12 
    13 const int maxn = 1e6+7;
    14 
    15 struct Time{
    16     int h, m, s;
    17 }Max, Min;
    18 
    19 int Maxid;
    20 int Minid;
    21 
    22 struct node{
    23     char Name[55];
    24     Time in, out;
    25 }a[maxn];
    26 
    27 void sw(Time &x, Time &y){
    28     x.h = y.h; x.m = y.m; x.s = y.s;
    29 }
    30 
    31 int main(){
    32     int t; t = read();
    33     Max.h = -1; Min.h = 25;
    34     Max.m = Max.s = Min.m = Min.s = 0;
    35     for(int i = 0;i < t;i++){
    36         scanf("%s", a[i].Name);
    37 
    38         scanf("%d:%d:%d", &a[i].in.h, &a[i].in.m, &a[i].in.s);
    39         if(Min.h > a[i].in.h){
    40             sw(Min, a[i].in), Minid = i;
    41         }
    42         else if(Min.h == a[i].in.h){
    43             if(Min.m > a[i].in.m){
    44                 sw(Min, a[i].in), Minid = i;
    45             }
    46             else if(Min.m == a[i].in.m){
    47                 if(Min.s > a[i].in.s) sw(Min, a[i].in), Minid = i;
    48             }
    49         }
    50 
    51         scanf("%d:%d:%d", &a[i].out.h, &a[i].out.m, &a[i].out.s);
    52         if(Max.h < a[i].out.h){
    53             sw(Max, a[i].out), Maxid = i;
    54         }
    55         else if(Max.h == a[i].out.h){
    56             if(Max.m < a[i].out.m){
    57                 sw(Max, a[i].out), Maxid = i;
    58             }
    59             else if(Max.m == a[i].out.m){
    60                 if(Max.s < a[i].out.s) sw(Max, a[i].out), Maxid = i;
    61             }
    62         }
    63     }
    64     printf("%s %s
    ", a[Minid].Name, a[Maxid].Name);
    65     return 0;
    66 }
  • 相关阅读:
    ASP.NET MVC应用程序更新相关数据
    HTML5 教程
    Nginx+Tomcat+Keepalived+Memcache 负载均衡动静分离技术
    Bootstrap 模态框
    Routing(路由) & Multiple Views(多个视图) step 7
    构建日均千万PV Web站点1
    基础模块
    Visual Studio 换颜色
    动手实现Expression翻译器1
    ASP.NET SignalR 2.0入门指南
  • 原文地址:https://www.cnblogs.com/ouyang_wsgwz/p/10108400.html
Copyright © 2011-2022 走看看