#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(x,t) for(ll x=0; x<(t); x++)
int main ()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
map <int, int> M;
cin>>n;
int ilosc = 0;
for(int i=0; i<n;i++){
int x;
cin>>x;
M[x]++;
if(M[x]==1) ilosc++;
}
vector<int> V;
for(auto &it: M){
V.push_back(it.second);
}
sort(V.begin(), V.end());
int pocz = 0;
for(int i=1; i<=n; i++){
if(pocz >= V.size()){
cout<<0<<" ";
continue;
}
while(pocz < V.size()){
if(V[pocz] < i ){
pocz++;
continue;
}
break;
}
int ans = 0;
for(int j = pocz; j<V.size(); j++){
ans+=(V[j]/i)*i;
}
cout<<ans<<" ";
}
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 | #include<bits/stdc++.h> using namespace std; typedef long long ll; #define REP(x,t) for(ll x=0; x<(t); x++) int main () { ios_base::sync_with_stdio(0); cin.tie(0); int n; map <int, int> M; cin>>n; int ilosc = 0; for(int i=0; i<n;i++){ int x; cin>>x; M[x]++; if(M[x]==1) ilosc++; } vector<int> V; for(auto &it: M){ V.push_back(it.second); } sort(V.begin(), V.end()); int pocz = 0; for(int i=1; i<=n; i++){ if(pocz >= V.size()){ cout<<0<<" "; continue; } while(pocz < V.size()){ if(V[pocz] < i ){ pocz++; continue; } break; } int ans = 0; for(int j = pocz; j<V.size(); j++){ ans+=(V[j]/i)*i; } cout<<ans<<" "; } return 0; } |
English