• 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

    题目大意是先告诉你今天一共有n个人出入机房,接下来的n行里每行第一串字符表示编号,第二个表示进入时间,第三个表示离开时间,求最早进入和最晚离开人员的编号
     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cstring>
     4 using namespace std;
     5 int main()
     6 {
     7     int n;
     8     string name,n1,n2;
     9     int a1,a2,a3,a;
    10     int b1,b2,b3,b;
    11     while(scanf("%d",&n)!=EOF)
    12     {
    13         int la=0,sm=1e9;
    14         string name1,name2;
    15         for(int i=0;i<n;i++)
    16         {
    17             cin>>name;
    18             scanf("%d:%d:%d",&a1,&a2,&a3);
    19             scanf("%d:%d:%d",&b1,&b2,&b3);
    20             a=a1*10000+a2*100+a3;
    21             b=b1*10000+b2*100+b3;
    22             if(a<sm)
    23             {
    24                 sm=a;
    25                 name1=name;
    26             }
    27             if(b>la)
    28             {
    29                 la=b;
    30                 name2=name;
    31             }
    32         }
    33         cout << name1 <<" " <<name2 <<endl;
    34     }
    35 }
     
  • 相关阅读:
    php_l3arning_notes_3
    php_l3arning_notes_2
    php_l3arning_notes_1
    从 HTTP 到 HTTPS 再到 HSTS
    WSGI&ASGI
    WSGI 介绍
    什么是multipart/form-data请求
    SSH 端口转发
    Redis与RabbitMQ作为消息队列的比较
    数据库索引,到底是什么做的?
  • 原文地址:https://www.cnblogs.com/LowBee/p/10439636.html
Copyright © 2020-2023  润新知