#include <iostream>
#include <unordered_map>
#include <vector>
std::unordered_map<int, int> mapka;
int n;
void input() {
scanf("%d", &n);
int x;
for(int i = 0; i < n; i++) {
scanf("%d", &x);
mapka[x]++;
}
}
int query(int k) {
std::vector<int> toDelete;
int ans = 0;
for(const auto& [key, val] : mapka) {
if(val < k)
toDelete.push_back(key);
ans += (val / k) * k;
}
for(const auto& key : toDelete)
mapka.erase(key);
return ans;
}
int main() {
input();
for(int i = 1; i <= n; i++)
printf("%d ", query(i));
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include <iostream> #include <unordered_map> #include <vector> std::unordered_map<int, int> mapka; int n; void input() { scanf("%d", &n); int x; for(int i = 0; i < n; i++) { scanf("%d", &x); mapka[x]++; } } int query(int k) { std::vector<int> toDelete; int ans = 0; for(const auto& [key, val] : mapka) { if(val < k) toDelete.push_back(key); ans += (val / k) * k; } for(const auto& key : toDelete) mapka.erase(key); return ans; } int main() { input(); for(int i = 1; i <= n; i++) printf("%d ", query(i)); return 0; } |
English