【PAT】A1006. Sign In and Sign Out (25)

A1006. Sign In and Sign Out (25)

#include <stdio.h>

struct person {
    char id[16];
    int h, m, s;
}tmp, unlock, lock;

int earlier(struct person p1, struct person p2){
    if(p1.h != p2.h)
        return p1.h < p2.h;
    else if(p1.m != p2.m)
        return p1.m < p2.m;
    else
        return p1.s < p2.s;
}

int main(){
    int N;
    scanf("%d", &N);
    unlock.h = 24;
    unlock.m = unlock.s = 60;
    lock.h = lock.m = lock.s = 0;
    for(int i = 0; i < N; i++){
        scanf("%s %d:%d:%d", tmp.id, &tmp.h, &tmp.m, &tmp.s);
        if(earlier(tmp, unlock))
            unlock = tmp;
        scanf("%d:%d:%d", &tmp.h, &tmp.m, &tmp.s);
        if(!earlier(tmp, lock))
            lock = tmp;
    }

    printf("%s %s", unlock.id, lock.id);

    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值