No.706 Survey of Many-Eyed Creatures
Problem Statement
On a certain planet, there live creatures with various numbers of eyes. A scholar studying these creatures, in order to investigate the distribution of the number of eyes, has decided for now to represent each creature using as many "^" as it has eyes.
For example, a creature with 2 eyes is represented as "(^^)", and one with 5 eyes as "(^^^^^)".
Output the number of eyes observed most frequently among the N creatures (the mode). (This is not the maximum value.)
If there are multiple possible answers, output the larger one.
Input
N S1 S2 .... Sn
The number N of creatures examined is given, followed by N lines containing the figures S1,S2....Sn such as (^^).
1<=N<=1000
2<=|S|<=1000
Output
Output the most frequently observed number of eyes. Print a newline at the end.
Sample
Sample 1
Input
5 (^^) (^^^) (^^) (^^^) (^^)
Output
2
There were 3 creatures with 2 eyes and 2 creatures with 3 eyes, so 2 eyes was observed most frequently.
Sample 2
Input
1 (^^^^^)
Output
5
Sample 3
Input
10 (^^) (^) (^^^^^^) (^^^^) (^^^^) (^^^^^^^^^^) (^^^) (^^^^^^^) (^^^^^^^^^^^) (^^^^^^)
Output
6
There were 2 creatures each with 4 eyes and with 6 eyes, and 1 creature each for every other number of eyes. The larger number of eyes is the answer, so the answer is 6.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
gotutiyan