【PAT甲级】1006 Sign In and Sign Out

题目链接:1006 Sign In and Sign Out

#include <iostream>
using namespace std;

int main(){
    int M, in = 240000, out = -1, h, m, s;
    string id, inid, outid;
    cin >> M;
    for(int i = 0; i < M; i++){
        cin >> id;
        scanf("%d:%d:%d", &h, &m, &s);
        s = h * 10000 + m * 100 + s;
        if(s < in){
            in = s;
            inid = id;
        }
        scanf("%d:%d:%d", &h, &m, &s);
        s = h * 10000 + m * 100 + s;
        if(s > out){
            out = s;
            outid = id;
        }
    }
    cout << inid << ' ' << outid;
}

 

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页