问题 5261 --人口普查(people.cpp)

5261: 人口普查(people.cpp)★★★

时间限制: 1 Sec  内存限制: 128 MB
提交: 43  解决: 22
[提交][状态][命题人:]

题目描述

某城镇进行人口普查,得到了全体居民的生日。现请你写个程序,找出镇上最年长和最年轻的人。

这里确保每个输入的日期都是合法的,但不一定是合理的——假设已知镇上没有超过 200 岁的老人,假设今天是 2014 年 9 月 6 日,那么超过 200 岁的生日和未出生的生日都是不合理的,应该被过滤掉。

A town conducted a census and got the birthdays of all its residents. Now, please write a program to find the oldest and youngest people in town.
Here it is ensured that each date entered is legal, but not necessarily reasonable - assuming it is known that no one in town is over 200 years old, and assuming that today is September 6, 2014, then birthdays over 200 and unborn birthdays are both unreasonable and should be filtered out.

输入

输入在第一行给出正整数  ,取值在 (0,1e5;随后   行,每行给出  1  个人的姓名(由不超过  5  个英文字母组成的字符串)、以及按  yyyy/mm/dd( 即年/月/日)格式给出的生日。

The input gives a positive integer N in the first line, with values in the range [0,1e5]; This is followed by N lines, each giving a person's name (a string of up to five English letters) and a date of birth in yyyy/mm/dd (year/month/day) format.

输出

在一行中顺序输出有效生日的个数、最年长人和最年轻人的姓名,其间以空格分隔。

Output the number of valid birthdays and the names of the oldest and youngest, separated by space, in order on one line.

样例输入
Copy
5
John 2001/05/12
Tom 1814/09/06
Ann 2121/01/30
James 1814/09/05
Steve 1967/11/20
样例输出
Copy
3 Tom John

提示

来源

 

[提交][状态]