#include <bits/stdc++.h>
using namespace std;
constexpr int M = 300'005;
map<int, int> mapa;
long long tab[M];
bool czy(int a, int b){ return a > b; }
int main(){
cin.tie(0)->sync_with_stdio(0);
long long n;
cin>>n;
for(int i=1; i<=n; i++){
int temp;
cin>>temp;
mapa[temp]++;
}
int akt = 1;
for(auto i:mapa) tab[akt++] = i.second;
sort(tab+1, tab+n+1, czy);
for(int i=1; i<=n; i++){
int ile = 0;
for(int j=1; j<=n; j++){
if(i > tab[j]) break;
ile = ile + (tab[j]/i) * i;
}
cout<<ile<<" ";
}
cout<<endl;
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 | #include <bits/stdc++.h> using namespace std; constexpr int M = 300'005; map<int, int> mapa; long long tab[M]; bool czy(int a, int b){ return a > b; } int main(){ cin.tie(0)->sync_with_stdio(0); long long n; cin>>n; for(int i=1; i<=n; i++){ int temp; cin>>temp; mapa[temp]++; } int akt = 1; for(auto i:mapa) tab[akt++] = i.second; sort(tab+1, tab+n+1, czy); for(int i=1; i<=n; i++){ int ile = 0; for(int j=1; j<=n; j++){ if(i > tab[j]) break; ile = ile + (tab[j]/i) * i; } cout<<ile<<" "; } cout<<endl; return 0; } |
English