#include <unistd.h>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <deque>
#include <iostream>
#include <algorithm>
// using namespace std;
#define REP(i, n) for (int _n = (n), i = 0; i < _n; ++i)
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define TRACE(x) cerr << "TRACE(" #x ")" << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef unsigned long long ULL;
using VINT = std::vector<int>;
using VLL = std::vector<LL>;
using VULL = std::vector<ULL>;
int main()
{
std::ios_base::sync_with_stdio(false);
std::map<int, int> m;
int n, a;
std::cin >> n;
for (int i = 0; i < n; i++)
{
std::cin >> a;
m[a]++;
}
VINT v;
for (auto it = m.rbegin(); it != m.rend(); it++)
v.push_back(it->second);
sort(v.rbegin(), v.rend());
std::cout << n;
for (int i = 2; i <= n; i++) {
int sum = 0;
for (auto vv : v) {
if (vv < i) break;
sum += (vv / i) * i;
}
std::cout << " " << sum;
}
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 52 53 54 55 | #include <unistd.h> #include <string> #include <vector> #include <map> #include <set> #include <utility> #include <deque> #include <iostream> #include <algorithm> // using namespace std; #define REP(i, n) for (int _n = (n), i = 0; i < _n; ++i) #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i) #define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; --i) #define TRACE(x) cerr << "TRACE(" #x ")" << endl; #define DEBUG(x) cerr << #x << " = " << (x) << endl; typedef long long LL; typedef unsigned long long ULL; using VINT = std::vector<int>; using VLL = std::vector<LL>; using VULL = std::vector<ULL>; int main() { std::ios_base::sync_with_stdio(false); std::map<int, int> m; int n, a; std::cin >> n; for (int i = 0; i < n; i++) { std::cin >> a; m[a]++; } VINT v; for (auto it = m.rbegin(); it != m.rend(); it++) v.push_back(it->second); sort(v.rbegin(), v.rend()); std::cout << n; for (int i = 2; i <= n; i++) { int sum = 0; for (auto vv : v) { if (vv < i) break; sum += (vv / i) * i; } std::cout << " " << sum; } return 0; } |
English