#include <bits/stdc++.h>
using namespace std;
int n, a;
unordered_map<int, int> zlicz;
int wynik[300000];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> a;
auto it = zlicz.find(a);
if (it == zlicz.end()) zlicz[a] = 1;
else it->second++;
}
for (const auto& it : zlicz)
{
for (int i = 0; i < it.second; i++)
wynik[i] += (it.second / (i + 1)) * (i + 1);
}
for (int i = 0; i < n; i++)
cout << wynik[i] << ' ';
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; int n, a; unordered_map<int, int> zlicz; int wynik[300000]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for (int i = 0; i < n; i++) { cin >> a; auto it = zlicz.find(a); if (it == zlicz.end()) zlicz[a] = 1; else it->second++; } for (const auto& it : zlicz) { for (int i = 0; i < it.second; i++) wynik[i] += (it.second / (i + 1)) * (i + 1); } for (int i = 0; i < n; i++) cout << wynik[i] << ' '; return 0; } |
English