PAT--1006 Sign In and Sign Out

#include <iostream>
#include <string>
#include <stdio.h>
#define MAX 25
#define MIN -1

using namespace std;

struct Node
{
    int h, m, s;
};


int main()
{
    int n;
    string str, str_in, str_out;
    Node time[2];
    scanf("%d", &n);
    int he,me,se,hl,ml,sl;
    he = me = se = MAX;
    hl = ml = sl = MIN;
    while(n--)
    {
        cin >> str;
        scanf("%d:%d:%d", &time[0].h, &time[0].m, &time[0].s);
        scanf("%d:%d:%d", &time[1].h, &time[1].m, &time[1].s);
        if(time[0].h < he)
        {
             str_in = str;
             he = time[0].h;
        }

        else if(time[0].h == he)
        {
            if(time[0].m < me)
            {
                str_in = str;
                me = time[0].m;
            }
            else if(time[0].m == me)
                if(time[0].s < se)
                {
                    str_in = str;
                    se = time[0].s;
                }

        }
        if(time[1].h > hl)
        {
            str_out = str;
            hl = time[1].h;
        }
        else if(time[1].h == hl)
        {
            if(time[1].m < ml)
            {
                str_out = str;
                ml = time[1].m;
            }
            else if(time[1].m == ml)
                if(time[1].s < sl)
                {
                    str_out = str;
                    sl = time[1].s;
                }

        }
    }
    cout << str_in << " " << str_out << endl;

    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值