Skip to content

Instantly share code, notes, and snippets.

@yurahuna
Created October 2, 2016 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yurahuna/fe6800f025a607fa2d75e9c01fb55303 to your computer and use it in GitHub Desktop.
Save yurahuna/fe6800f025a607fa2d75e9c01fb55303 to your computer and use it in GitHub Desktop.
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int n, k;
cin >> n >> k;
vi cnt(26);
rep(i, n) {
string s;
cin >> s;
cnt[s[0] - 'A']++;
}
int ans = 0;
while (true) {
sort(rall(cnt));
rep(i, k) {
if (cnt[i] == 0) {
cout << ans << endl;
return 0;
}
cnt[i]--;
}
ans++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment