#include <iostream> #include <vector> #include <algorithm> #include <math.h> #include <set> #include <map> #include <stack> #include <queue> #include <iomanip> using namespace std; typedef long long ll; const int N = 2e2 + 10; const int P = 101; const ll MLL = 1e18; const ll mod = 998244353; const ll LOG = 23; void solve() { int n; cin >> n; map<ll , int> mp; for(int i = 0; i <n; i++) { ll a; cin >> a; if(mp.find(a) == mp.end()) mp[a] = 0; mp[a]++; } vector<int> v; ll all = 0; for(auto x : mp) { v.push_back(x.second); all += x.second; } sort(v.begin(),v.end(),greater<int>()); for(int i = 1; i <= n; i++) { while(v.size() > 0 && v[v.size() - 1] < i) all -= v[v.size() - 1], v.pop_back(); ll ans = all; for(int j = 0; j < (int)v.size(); j++) { ans -= v[j] % i; } cout << ans << " "; } cout << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); solve(); 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 | #include <iostream> #include <vector> #include <algorithm> #include <math.h> #include <set> #include <map> #include <stack> #include <queue> #include <iomanip> using namespace std; typedef long long ll; const int N = 2e2 + 10; const int P = 101; const ll MLL = 1e18; const ll mod = 998244353; const ll LOG = 23; void solve() { int n; cin >> n; map<ll , int> mp; for(int i = 0; i <n; i++) { ll a; cin >> a; if(mp.find(a) == mp.end()) mp[a] = 0; mp[a]++; } vector<int> v; ll all = 0; for(auto x : mp) { v.push_back(x.second); all += x.second; } sort(v.begin(),v.end(),greater<int>()); for(int i = 1; i <= n; i++) { while(v.size() > 0 && v[v.size() - 1] < i) all -= v[v.size() - 1], v.pop_back(); ll ans = all; for(int j = 0; j < (int)v.size(); j++) { ans -= v[j] % i; } cout << ans << " "; } cout << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); solve(); return 0; } |