1006. Sign In and Sign Out (25)
888 ワード
時間を核心とするイベントシミュレーションを考察する
#include
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
", p_in.name, p_out.name);
}
return 0;
}