/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 266 点
問題文
高橋君は N 個の文字列 S_1, S_2, \ldots, S_N のリストを持っています。高橋君はこれらの文字列を、先頭の文字ごとにグループに分類しようとしています。すなわち、先頭の文字が同じ文字列はすべて同じグループに属し、先頭の文字が異なる文字列は異なるグループに属します。
文字列の数が最も多いグループに含まれる文字列の数を求めてください。ただし、リスト中に同じ文字列が複数回現れる場合でも、それらを区別してそれぞれ 1 個ずつ数えるものとします。すなわち、グループに含まれる文字列の数は重複除去をせずに数えます。
制約
- 1 \leq N \leq 10^5
- S_i は英小文字のみからなる長さ 1 以上 20 以下の文字列である。
入力
N S_1 S_2 \vdots S_N
1 行目には、文字列の数を表す整数 N が与えられる。続く N 行のうち i 行目には、文字列 S_i が与えられる。
出力
文字列の数が最も多いグループに含まれる文字列の数を 1 行で出力せよ。
入力例 1
5 apple apricot banana avocado berry
出力例 1
3
入力例 2
6 cat car dog dove eel egg
出力例 2
2
入力例 3
12 alpha atom angle beta banana boat boat cat circle cider apple ant
出力例 3
5
入力例 4
30 moon map milk mango mint mouse melon mild sun sand sea stone smile sound soup apple arrow ant book bird blue cat cloud camel dog drum echo earth zebra zero
出力例 4
8
入力例 5
1 abcdefghijklmnopqrst
出力例 5
1
Score : 266 pts
Problem Statement
Takahashi has a list of N strings S_1, S_2, \ldots, S_N. He wants to classify these strings into groups based on their first character. That is, all strings with the same first character belong to the same group, and strings with different first characters belong to different groups.
Find the number of strings in the group that contains the most strings. Note that even if the same string appears multiple times in the list, each occurrence is counted separately as one string. In other words, the number of strings in a group is counted without removing duplicates.
Constraints
- 1 \leq N \leq 10^5
- S_i is a string consisting only of lowercase English letters with length between 1 and 20, inclusive.
Input
N S_1 S_2 \vdots S_N
The first line contains an integer N representing the number of strings. The i-th of the following N lines contains the string S_i.
Output
Print in one line the number of strings in the group that contains the most strings.
Sample Input 1
5 apple apricot banana avocado berry
Sample Output 1
3
Sample Input 2
6 cat car dog dove eel egg
Sample Output 2
2
Sample Input 3
12 alpha atom angle beta banana boat boat cat circle cider apple ant
Sample Output 3
5
Sample Input 4
30 moon map milk mango mint mouse melon mild sun sand sea stone smile sound soup apple arrow ant book bird blue cat cloud camel dog drum echo earth zebra zero
Sample Output 4
8
Sample Input 5
1 abcdefghijklmnopqrst
Sample Output 5
1