#include <bits/stdc++.h> using namespace std; using ll = long long; #ifdef LOCAL #include "debug.h" #else #define debug(...) 2137 #endif int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; map<int, int> cnt, cc; cin >> n; for (int i = 0; i < n; i++) { int a; cin >> a; cnt[a]++; } for (auto [x, y] : cnt) { cc[y]++; } auto st = cc.begin(); for (int k = 1; k <= n; k++) { int ans = 0; while (st != cc.end() && st->first < k) { st++; } for (auto it = st; it != cc.end(); it++) { auto [x, y] = *it; ans += (x - x % k) * y; } cout << ans << " \n"[k == n]; } }
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 36 37 | #include <bits/stdc++.h> using namespace std; using ll = long long; #ifdef LOCAL #include "debug.h" #else #define debug(...) 2137 #endif int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; map<int, int> cnt, cc; cin >> n; for (int i = 0; i < n; i++) { int a; cin >> a; cnt[a]++; } for (auto [x, y] : cnt) { cc[y]++; } auto st = cc.begin(); for (int k = 1; k <= n; k++) { int ans = 0; while (st != cc.end() && st->first < k) { st++; } for (auto it = st; it != cc.end(); it++) { auto [x, y] = *it; ans += (x - x % k) * y; } cout << ans << " \n"[k == n]; } } |