#include <iostream> #include <algorithm> #include <vector> using namespace std; int main() { ios_base::sync_with_stdio(false); std::cin.tie(NULL); int n, x[300001]; cin>>n; for (int i=0; i<n; ++i) cin>>x[i]; sort(x, x+n); x[n]=2000000000; vector<int> l; for (int pocz=0, i=0; i<=n; ++i) if (x[i]!=x[pocz]) { l.push_back(i-pocz); pocz=i; } sort(l.begin(), l.end()); for (int k=1; k<=n; ++k) { int wyn=0; for (int i=l.size()-1; 0<=i; --i) { int ll=l[i]; if (ll<k) break; wyn+=ll-ll%k; } 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 | #include <iostream> #include <algorithm> #include <vector> using namespace std; int main() { ios_base::sync_with_stdio(false); std::cin.tie(NULL); int n, x[300001]; cin>>n; for (int i=0; i<n; ++i) cin>>x[i]; sort(x, x+n); x[n]=2000000000; vector<int> l; for (int pocz=0, i=0; i<=n; ++i) if (x[i]!=x[pocz]) { l.push_back(i-pocz); pocz=i; } sort(l.begin(), l.end()); for (int k=1; k<=n; ++k) { int wyn=0; for (int i=l.size()-1; 0<=i; --i) { int ll=l[i]; if (ll<k) break; wyn+=ll-ll%k; } cout<<wyn<<' '; } return 0; } |