#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") //a poem about frogs #include <bits/stdc++.h> #define ll long long #define lld long double #define ull unsigned long long #define st first #define nd second #define mp make_pair #define ii pair<int, int> #define vl vector<ll> #define vi vector<int> #define vvi vector<vector<int> > #define pb push_back #define eb emplace_back #define remax(a, b) a = max(a, b); #define remin(a, b) a = min(a, b); #define all(x) x.begin(), x.end() #define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define bit(n, x) (n & (1 << x)) #define rep(a, b) for(int a = 0; a < b; ++a) using namespace std; int main() { fastio(); int n; cin >> n; unordered_map<int, int> g; rep(i, n) { int j; cin >> j; if (g.find(j) == g.end()) g[j] = 0; ++g[j]; } vi res(n+1, 0); for (auto it : g) { int i = it.nd; //cerr << "test i " << i << '\n'; //res[1] += i; //so now i have the number of stamps, which is i for (int j = 1; j <= i; ++j) { //cerr << "j " << j << " i/j " << i/j << '\n'; res[j] += (i/j)*j; } } for (int i = 1; i <= n; ++i) cout << res[i] << ' '; cout << '\n'; 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") //a poem about frogs #include <bits/stdc++.h> #define ll long long #define lld long double #define ull unsigned long long #define st first #define nd second #define mp make_pair #define ii pair<int, int> #define vl vector<ll> #define vi vector<int> #define vvi vector<vector<int> > #define pb push_back #define eb emplace_back #define remax(a, b) a = max(a, b); #define remin(a, b) a = min(a, b); #define all(x) x.begin(), x.end() #define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define bit(n, x) (n & (1 << x)) #define rep(a, b) for(int a = 0; a < b; ++a) using namespace std; int main() { fastio(); int n; cin >> n; unordered_map<int, int> g; rep(i, n) { int j; cin >> j; if (g.find(j) == g.end()) g[j] = 0; ++g[j]; } vi res(n+1, 0); for (auto it : g) { int i = it.nd; //cerr << "test i " << i << '\n'; //res[1] += i; //so now i have the number of stamps, which is i for (int j = 1; j <= i; ++j) { //cerr << "j " << j << " i/j " << i/j << '\n'; res[j] += (i/j)*j; } } for (int i = 1; i <= n; ++i) cout << res[i] << ' '; cout << '\n'; return 0; } |