#include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int a; cin>>a; unordered_map<int,int>m; for(int z=0;z<a;z++) { int b; cin>>b; if(m.count(b)==0) { m.insert({b,0}); } m[b]++; } vector<int>v; int sum=0; for(unordered_map<int,int>::iterator z=m.begin();z!=m.end();z++) { v.push_back(z->second); sum+=z->second; } sort(v.begin(),v.end()); for(int z=1;z<=a;z++) { int wyn=sum; int pom=sum; for(int w=v.size()-1;w>=0;w--) { if(v[w]<z) { wyn-=pom; break; } wyn-=v[w]%z; pom-=v[w]; } cout<<wyn<<" "; } 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<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int a; cin>>a; unordered_map<int,int>m; for(int z=0;z<a;z++) { int b; cin>>b; if(m.count(b)==0) { m.insert({b,0}); } m[b]++; } vector<int>v; int sum=0; for(unordered_map<int,int>::iterator z=m.begin();z!=m.end();z++) { v.push_back(z->second); sum+=z->second; } sort(v.begin(),v.end()); for(int z=1;z<=a;z++) { int wyn=sum; int pom=sum; for(int w=v.size()-1;w>=0;w--) { if(v[w]<z) { wyn-=pom; break; } wyn-=v[w]%z; pom-=v[w]; } cout<<wyn<<" "; } return 0; } |