#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <unordered_map>
#include <assert.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/trie_policy.hpp>
//using namespace __gnu_pbds
using namespace std;
template<class A, class B>
ostream& operator<<(ostream& o, const pair<A, B>& p) {
return o << '(' << p.first << ", " << p.second << ')';
}
template<class A, class B, class C>
ostream& operator<<(ostream& o, const tuple<A, B, C>& t) {
return o << '(' << get<0>(t) << ", " << get<1>(t) << ", " << get<2>(t) << ')';
}
template<class T>
auto operator<<(ostream& o, const T& x) -> decltype(x.end(), o) {
o << '{';
int i = 0;
for (const auto& e : x) {
o << (", ") + 2 * !i++ << e;
}
return o << '}';
}
auto operator<<(ostream& o, const string& s) -> decltype(o) {
for (const auto& e : s) {
o << e;
}
return o;
}
//#define DEBUG
#ifdef DEBUG
#define fastio()
#define debug(x...) cerr << "[" #x "]: ", [](auto... $) {((cerr << $ << "; "), ...); }(x), cerr << '\n'
#define asrt(x) if (!(x)) { cerr << "Assertion failed: " << #x << " in line " << __LINE__ << endl; exit(1); }
#else
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0);
#define debug(...)
#define asrt(x)
#endif
#define pii pair<int,int>
#define inf 2'000'000'000
#define llinf 8'000'000'000'000'000'000
#define mod 998'244'353
#define mod7 1'000'000'007
#define mod9 1'000'000'009
#define eps 0.00000000001
#define all(x) x.begin(),x.end()
#define rev(x) x.rbegin(),x.rend()
#define decrease(x) x,vector<x>,greater<x>
#define maxn 300'000
typedef long long ll;
typedef long double ld;
vector <int> cnt;
int arr[maxn + 5];
void solve() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", &arr[i]);
sort(arr + 1, arr + n + 1);
for (int i = 1; i <= n; i++) {
if (arr[i] != arr[i - 1])cnt.push_back(1);
else cnt.back()++;
}
sort(all(cnt), greater<int>());
for (int k = 1; k <= n; k++) {
int scr = 0;
for (int i: cnt) {
scr += i / k;
if (i < k) break;
}
printf("%d ", scr * k);
}
printf("\n");
}
signed main() {
fastio();
int t = 1;
//cin >> t;
while (t--) solve();
}
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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <unordered_map> #include <assert.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/trie_policy.hpp> //using namespace __gnu_pbds using namespace std; template<class A, class B> ostream& operator<<(ostream& o, const pair<A, B>& p) { return o << '(' << p.first << ", " << p.second << ')'; } template<class A, class B, class C> ostream& operator<<(ostream& o, const tuple<A, B, C>& t) { return o << '(' << get<0>(t) << ", " << get<1>(t) << ", " << get<2>(t) << ')'; } template<class T> auto operator<<(ostream& o, const T& x) -> decltype(x.end(), o) { o << '{'; int i = 0; for (const auto& e : x) { o << (", ") + 2 * !i++ << e; } return o << '}'; } auto operator<<(ostream& o, const string& s) -> decltype(o) { for (const auto& e : s) { o << e; } return o; } //#define DEBUG #ifdef DEBUG #define fastio() #define debug(x...) cerr << "[" #x "]: ", [](auto... $) {((cerr << $ << "; "), ...); }(x), cerr << '\n' #define asrt(x) if (!(x)) { cerr << "Assertion failed: " << #x << " in line " << __LINE__ << endl; exit(1); } #else #define fastio() ios_base::sync_with_stdio(0); cin.tie(0); #define debug(...) #define asrt(x) #endif #define pii pair<int,int> #define inf 2'000'000'000 #define llinf 8'000'000'000'000'000'000 #define mod 998'244'353 #define mod7 1'000'000'007 #define mod9 1'000'000'009 #define eps 0.00000000001 #define all(x) x.begin(),x.end() #define rev(x) x.rbegin(),x.rend() #define decrease(x) x,vector<x>,greater<x> #define maxn 300'000 typedef long long ll; typedef long double ld; vector <int> cnt; int arr[maxn + 5]; void solve() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &arr[i]); sort(arr + 1, arr + n + 1); for (int i = 1; i <= n; i++) { if (arr[i] != arr[i - 1])cnt.push_back(1); else cnt.back()++; } sort(all(cnt), greater<int>()); for (int k = 1; k <= n; k++) { int scr = 0; for (int i: cnt) { scr += i / k; if (i < k) break; } printf("%d ", scr * k); } printf("\n"); } signed main() { fastio(); int t = 1; //cin >> t; while (t--) solve(); } |
English