1006. Sign In and Sign Out (25)

来源:互联网 发布:桌游矩阵潜袭 编辑:程序博客网 时间:2024/04/29 12:25

考察以时间为核心的事件模拟

#include<stdio.h>typedef struct person{char name[20];int in;int out;}Person;int main(){int m;while( scanf("%d", &m) != EOF ){Person p_in, p_out, tmp;int h1, h2, m1, m2, s1, s2;char inStr[20];char outStr[20];if(m == 0) continue;scanf("%s%d%*c%d%*c%d %d%*c%d%*c%d", tmp.name, &h1, &m1, &s1, &h2, &m2, &s2);tmp.in = h1*3600+m1*60+s1;tmp.out = h2*3600+m2*60+s2;p_in = p_out = tmp;m--;while(m--){scanf("%s%d%*c%d%*c%d %d%*c%d%*c%d", tmp.name, &h1, &m1, &s1, &h2, &m2, &s2);tmp.in = h1*3600+m1*60+s1;tmp.out = h2*3600+m2*60+s2;if(tmp.in < p_in.in) p_in = tmp;if(tmp.out > p_out.out) p_out = tmp;}printf("%s %s\n", p_in.name, p_out.name);}return 0;}