#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<char> VC;
typedef vector<vector<char>> VVC;
typedef vector<bool> VB;
typedef vector<vector<bool>> VVB;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<pair<int, int>> VPI;
typedef vector<pair<long long, long long>> VPL;
#define LINE '\n'
#define SPACE ' '
#define PB push_back
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
void solve() {
int n;
cin >> n;
map<int, int> mp;
FOR(i, 0, n) {
int a;
cin >> a;
mp[a]++;
}
VI ans(n + 1, 0);
for(auto &[key, val] : mp) {
for(int i = 1; i <= val; i++) {
ans[i] += (val/i) * i;
}
}
FOR(i, 1, n + 1) cout << ans[i] << SPACE;
cout << LINE;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
// cin >> t;
while (t--)
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 57 58 59 60 61 62 63 64 65 66 67 68 | #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef unsigned long long ull; typedef unsigned int uint; typedef vector<int> VI; typedef vector<vector<int>> VVI; typedef vector<long long> VL; typedef vector<vector<long long>> VVL; typedef vector<char> VC; typedef vector<vector<char>> VVC; typedef vector<bool> VB; typedef vector<vector<bool>> VVB; typedef pair<int, int> PII; typedef pair<long long, long long> PLL; typedef vector<pair<int, int>> VPI; typedef vector<pair<long long, long long>> VPL; #define LINE '\n' #define SPACE ' ' #define PB push_back #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define ALL(x) x.begin(), x.end() #define RALL(x) x.rbegin(), x.rend() void solve() { int n; cin >> n; map<int, int> mp; FOR(i, 0, n) { int a; cin >> a; mp[a]++; } VI ans(n + 1, 0); for(auto &[key, val] : mp) { for(int i = 1; i <= val; i++) { ans[i] += (val/i) * i; } } FOR(i, 1, n + 1) cout << ans[i] << SPACE; cout << LINE; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; // cin >> t; while (t--) solve(); } |
English