// Witold Milewski // PA 2024 #include <bits/stdc++.h> using namespace std; #define int long long #define FOR(i, a, b) for(int i=a; i<=b; ++i) #define ll long long #define pi pair<int, int> #define f first #define s second #define eb emplace_back #define pb push_back #define sz(A) (int)(A.size()) const int maxn=3e5+3; int A[maxn], X[maxn], res[maxn], n; map<int, int> zlicz; int32_t main() { cin.tie(0) -> ios_base::sync_with_stdio(0); cin >> n; FOR(i, 1, n) cin >> A[i], ++zlicz[A[i]]; int idx=0; for(auto &[_, val] : zlicz) X[++idx]=val; FOR(i, 1, idx) { int x = X[i]; FOR(j, 1, x) res[j]+=(x/j)*j; } FOR(i, 1, n) cout << res[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 | // Witold Milewski // PA 2024 #include <bits/stdc++.h> using namespace std; #define int long long #define FOR(i, a, b) for(int i=a; i<=b; ++i) #define ll long long #define pi pair<int, int> #define f first #define s second #define eb emplace_back #define pb push_back #define sz(A) (int)(A.size()) const int maxn=3e5+3; int A[maxn], X[maxn], res[maxn], n; map<int, int> zlicz; int32_t main() { cin.tie(0) -> ios_base::sync_with_stdio(0); cin >> n; FOR(i, 1, n) cin >> A[i], ++zlicz[A[i]]; int idx=0; for(auto &[_, val] : zlicz) X[++idx]=val; FOR(i, 1, idx) { int x = X[i]; FOR(j, 1, x) res[j]+=(x/j)*j; } FOR(i, 1, n) cout << res[i] << ' '; cout << '\n'; } |