mirror of
https://gitlab.com/mfocko/Codeforces.git
synced 2024-12-22 11:51:24 +01:00
feat(cpp): implement ‹collect_count›
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
5fa844da30
commit
78e46a06ff
1 changed files with 13 additions and 0 deletions
|
@ -150,6 +150,19 @@ Container collect(std::size_t size) {
|
||||||
collect(c, size);
|
collect(c, size);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
std::map<T, std::size_t> collect_count(std::size_t size) {
|
||||||
|
std::map<T, std::size_t> counts;
|
||||||
|
|
||||||
|
for (auto i = 0u; i < size; ++i) {
|
||||||
|
T x;
|
||||||
|
std::cin >> x;
|
||||||
|
++counts[x];
|
||||||
|
}
|
||||||
|
|
||||||
|
return counts;
|
||||||
|
}
|
||||||
#pragma endregion /* input */
|
#pragma endregion /* input */
|
||||||
|
|
||||||
#pragma region math
|
#pragma region math
|
||||||
|
|
Loading…
Reference in a new issue