#include<cstdio>
struct Person{
char name[10];
int yy,mm,dd;
}oldest,youngest,left,right,temp;
bool lessequ(Person a,Person b)
{
if(a.yy!=b.yy) return a.yy <= b.yy;
else if(a.mm!=b.yy) return a.mm<=b.mm;
else return a.dd = b.dd;
}
bool moreequ(Person a,Person b)
{
if(a.yy!=b.yy) return a.yy >= b.yy;
else if(a.mm!=b.yy) return a.mm>=b.mm;
else return a.dd = b.dd;
}
void init()
{
youngest.yy = left.yy = 1814;
oldest.yy = right.yy = 2014;
youngest.mm = oldest.mm = left.mm = right.mm = 9;
youngest.dd = oldest.dd = left.dd = right.dd = 6;
}
int main()
{
init();
int n,num = 0;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%s %d/%d/%d",temp.name,&temp.yy,&temp.mm,&temp.dd);
if(moreequ(temp,left)&&lessequ(temp,right))
{
if(moreequ(temp,youngest)) youngest = temp;
if(lessequ(temp,oldest)) oldest = temp;
num++;
}
}
if(num ==0) printf("0\n");
else printf("%d %s %s\n",num,oldest.name,youngest.name);
return 0;
}
PAT B1028
最新推荐文章于 2024-09-04 18:55:10 发布