// Kacper Orszulak #ifndef DEBUG #define NDEBUG #endif #include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vll = vector<ll>; using vb = vector<bool>; using vvi = vector<vi>; using vvll = vector<vll>; #define st first #define nd second #define pb push_back #define rep(i, n) for (int i = 0; i < int(n); ++i) #define whole(x) x.begin(), x.end() [[maybe_unused]] constexpr int INF = 1e9+7; template<class T> bool minR(T &a, const T &b) { if (b < a) { a = b; return true; } else return false; } template<class T> bool maxR(T &a, const T &b) { if (b > a) { a = b; return true; } else return false; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; map<int, int> m; cin >> n; rep(i, n) { int val; cin >> val; ++m[val]; } vi output(n+1, 0); for (const auto &[val, cnt] : m) { for (int i = 1; i <= cnt; ++i) { output[i] += cnt / i; } } for (int i = 1; i <= n; ++i) { cout << output[i] * i << " "; } cout << '\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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | // Kacper Orszulak #ifndef DEBUG #define NDEBUG #endif #include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vll = vector<ll>; using vb = vector<bool>; using vvi = vector<vi>; using vvll = vector<vll>; #define st first #define nd second #define pb push_back #define rep(i, n) for (int i = 0; i < int(n); ++i) #define whole(x) x.begin(), x.end() [[maybe_unused]] constexpr int INF = 1e9+7; template<class T> bool minR(T &a, const T &b) { if (b < a) { a = b; return true; } else return false; } template<class T> bool maxR(T &a, const T &b) { if (b > a) { a = b; return true; } else return false; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; map<int, int> m; cin >> n; rep(i, n) { int val; cin >> val; ++m[val]; } vi output(n+1, 0); for (const auto &[val, cnt] : m) { for (int i = 1; i <= cnt; ++i) { output[i] += cnt / i; } } for (int i = 1; i <= n; ++i) { cout << output[i] * i << " "; } cout << '\n'; } |