#include <bits/stdc++.h> using namespace std; map<int, int> Stamps; vector<int> Stamps2; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, x; cin >> n; for(int i = 0; i < n; i++) { cin >> x; Stamps[x]++; } for(auto e : Stamps) Stamps2.push_back(e.second); sort(Stamps2.begin(), Stamps2.end()); int start = 0, n2 = n; for(int i = 1; i <= n; i++) { int sum_mod = 0; for(int j = start; j < Stamps2.size(); j++) { if(Stamps2[j] < i) { n2 -= Stamps2[j]; start = j+1; } else sum_mod += Stamps2[j] % i; } cout << n2 - sum_mod << " "; } }
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 | #include <bits/stdc++.h> using namespace std; map<int, int> Stamps; vector<int> Stamps2; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, x; cin >> n; for(int i = 0; i < n; i++) { cin >> x; Stamps[x]++; } for(auto e : Stamps) Stamps2.push_back(e.second); sort(Stamps2.begin(), Stamps2.end()); int start = 0, n2 = n; for(int i = 1; i <= n; i++) { int sum_mod = 0; for(int j = start; j < Stamps2.size(); j++) { if(Stamps2[j] < i) { n2 -= Stamps2[j]; start = j+1; } else sum_mod += Stamps2[j] % i; } cout << n2 - sum_mod << " "; } } |