#include <ios> #include <ranges> #include <functional> #include <cassert> #include <vector> #define REP(i, n) for(int i=0; i<(n); ++i) #define SREP(n) REP(_ ## n, n) #define FOR(i, p, n) for(int i=(p); i<=(n); ++i) #define RFOR(i, p, n) for(int i=(p); i>=(n); --i) #define pb push_back #define eb emplace_back #define C const #define V std::vector #define F std::function #define R std::ranges #define RV std::ranges::views #define sz(A) int(A.size()) #define all(A) A.begin(), A.end() #define rall(A) A.rbegin(), A.rend() typedef long long ll; typedef long double ld; typedef V <int> vi; typedef V <vi> vvi; typedef V <bool> vb; typedef V <char> vc; typedef V <ll> vll; typedef const int ci; typedef const ll cll; int I(){ int z; while ((z=getchar_unlocked())<'0'||z>'9'); int r=z-'0'; while ((z=getchar_unlocked())>='0'&&z<='9') r=r*10+z-'0'; return r; } int main(){ ci n=I(); std::unordered_map <int, int> mapa; SREP(n) ++mapa[I()]; vi wyn(n); for (ci l : mapa | RV::values) REP(i, l) wyn[i]+=l-l%(i+1); for (ci i : wyn) printf("%d ", i); printf("\n"); }
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 | #include <ios> #include <ranges> #include <functional> #include <cassert> #include <vector> #define REP(i, n) for(int i=0; i<(n); ++i) #define SREP(n) REP(_ ## n, n) #define FOR(i, p, n) for(int i=(p); i<=(n); ++i) #define RFOR(i, p, n) for(int i=(p); i>=(n); --i) #define pb push_back #define eb emplace_back #define C const #define V std::vector #define F std::function #define R std::ranges #define RV std::ranges::views #define sz(A) int(A.size()) #define all(A) A.begin(), A.end() #define rall(A) A.rbegin(), A.rend() typedef long long ll; typedef long double ld; typedef V <int> vi; typedef V <vi> vvi; typedef V <bool> vb; typedef V <char> vc; typedef V <ll> vll; typedef const int ci; typedef const ll cll; int I(){ int z; while ((z=getchar_unlocked())<'0'||z>'9'); int r=z-'0'; while ((z=getchar_unlocked())>='0'&&z<='9') r=r*10+z-'0'; return r; } int main(){ ci n=I(); std::unordered_map <int, int> mapa; SREP(n) ++mapa[I()]; vi wyn(n); for (ci l : mapa | RV::values) REP(i, l) wyn[i]+=l-l%(i+1); for (ci i : wyn) printf("%d ", i); printf("\n"); } |