//Jakub Nowak XIV LO Wroclaw
#include<bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0);
#define int long long
#define vi vector<int>
#define pb push_back
#define st first
#define nd second
void wypisz(auto &X) {
for(auto &x : X) cout << x << " ";
cout << "\n";
}
void solve() {
int n;
unordered_map<int, int> M;
vi T;
vi ANS;
cin >> n;
T = vi(n+1, 0);
ANS = vi(n+1, 0);
for(int i=1; i<=n; i++) {
int x;
cin >> x;
M[x]++;
}
for(auto &u : M) {
//cout << u.nd << " ";
for(int j=1; u.nd/j > 0; j++) {
int ile_dzieci = u.nd/j; //ile (maksymalnie) dzieci moze dostac j znaczkow
T[ile_dzieci] ++;
}
}
int s = 0;
for(int i=n; i>=1; i--) {
s+= T[i];//s to liczba znaczkow, ktore dostanie kazde dziecko
ANS[i] = s*i;
}
for(int i=1; i<=n; i++) cout << ANS[i] << " ";
cout << "\n";
//wypisz(T);
//wypisz()
}
int32_t main() {
boost
solve();
}
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 | //Jakub Nowak XIV LO Wroclaw #include<bits/stdc++.h> using namespace std; #define boost ios_base::sync_with_stdio(false); cin.tie(0); #define int long long #define vi vector<int> #define pb push_back #define st first #define nd second void wypisz(auto &X) { for(auto &x : X) cout << x << " "; cout << "\n"; } void solve() { int n; unordered_map<int, int> M; vi T; vi ANS; cin >> n; T = vi(n+1, 0); ANS = vi(n+1, 0); for(int i=1; i<=n; i++) { int x; cin >> x; M[x]++; } for(auto &u : M) { //cout << u.nd << " "; for(int j=1; u.nd/j > 0; j++) { int ile_dzieci = u.nd/j; //ile (maksymalnie) dzieci moze dostac j znaczkow T[ile_dzieci] ++; } } int s = 0; for(int i=n; i>=1; i--) { s+= T[i];//s to liczba znaczkow, ktore dostanie kazde dziecko ANS[i] = s*i; } for(int i=1; i<=n; i++) cout << ANS[i] << " "; cout << "\n"; //wypisz(T); //wypisz() } int32_t main() { boost solve(); } |
English