#include <bits/stdc++.h>
using namespace std;
bool test(int a,int b)
{
return a>b;
}
unordered_map<int,int> ma;
vector<int> acc;
vector<int> tab;
int main()
{
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
int N;cin>>N;
for(int i=0;i<N;i++)
{
int x;cin>>x;
if(ma[x]==0)
{
acc.push_back(x);
}
ma[x]++;
}
for(int i=0;i<acc.size();i++)
{
tab.push_back(ma[acc[i]]);
}
sort(tab.begin(),tab.end(),test);
int i=1;
int last=tab.size();
for(i;i<=N;i++)
{
int res=0;
for(int j=0;j<last;j++)
{
int x=tab[j]-(tab[j]%i);
if(x==0){last=j;break;}
res+=x;
}
cout<<res<<" ";
}
}
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 | #include <bits/stdc++.h> using namespace std; bool test(int a,int b) { return a>b; } unordered_map<int,int> ma; vector<int> acc; vector<int> tab; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); int N;cin>>N; for(int i=0;i<N;i++) { int x;cin>>x; if(ma[x]==0) { acc.push_back(x); } ma[x]++; } for(int i=0;i<acc.size();i++) { tab.push_back(ma[acc[i]]); } sort(tab.begin(),tab.end(),test); int i=1; int last=tab.size(); for(i;i<=N;i++) { int res=0; for(int j=0;j<last;j++) { int x=tab[j]-(tab[j]%i); if(x==0){last=j;break;} res+=x; } cout<<res<<" "; } } |
English