Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=300005;
map<int,int> cnt,cnt2;
int ans[N],a[N];

int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; 
  int n;
  cin>>n;
  rep(i,1,n+1)
    cin>>a[i],cnt[a[i]]++;
  vi v2;
  for(auto it:cnt) v2.pb(it.se);
  sort(all(v2));
  for(auto it2:v2) cnt2[it2]++;
  vector<ii> v;
  for(auto it:cnt2) v.pb(it);
  rep(i,1,sz(v2)+1)
    {
      unordered_map<int,int> m(cnt2);
      vector<ii> tmp(v);
      vector<ii> changes;
      while(true)
	{
	  changes.clear();
	  int curr=0;
	  bool ok=true;
	  repv(j,0,sz(tmp))
	    {
	      if(tmp[j].fi==0)
		{
		  ok=false;
		  break;
		}
	      m.erase(tmp[j].fi);
	      if(curr+tmp[j].se<i)
		{
		  curr+=tmp[j].se;
		  changes.emplace_back(tmp[j]);
		}
	      else
		{
		  changes.emplace_back(mp(tmp[j].fi,i-curr));
		  if(tmp[j].se-i+curr)
		    m[tmp[j].fi]=tmp[j].se-i+curr;
		  break;
		}
	    }
	  if(!ok) break;
	  for(auto it:changes)
	    m[it.fi-1]+=it.se;
	  ans[i]++;
	  tmp.clear();
	  for(auto it:m) tmp.pb(it); sort(all(tmp));
	}
    }
  rep(i,1,n+1) cout<<ans[i]<<endl;
  return 0 ;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:59:36: error: no matching function for call to 'std::unordered_map<int, int>::unordered_map(std::map<int, int>&)'
   59 |       unordered_map<int,int> m(cnt2);
      |                                    ^
In file included from /usr/include/c++/14/unordered_map:41,
                 from /usr/include/c++/14/functional:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/unordered_map.h:259:9: note: candidate: 'template<class _InputIterator> std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(_InputIterator, _InputIterator, size_type, const hasher&, const allocator_type&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
  259 |         unordered_map(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:259:9: note:   candidate expects 5 arguments, 1 provided
/usr/include/c++/14/bits/unordered_map.h:252:9: note: candidate: 'template<class _InputIterator> std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(_InputIterator, _InputIterator, size_type, const allocator_type&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
  252 |         unordered_map(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:252:9: note:   candidate expects 4 arguments, 1 provided
/usr/include/c++/14/bits/unordered_map.h:179:9: note: candidate: 'template<class _InputIterator> std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(_InputIterator, _InputIterator, size_type, const hasher&, const key_equal&, const allocator_type&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
  179 |         unordered_map(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:179:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/unordered_map.h:271:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(std::initializer_list<typename std::_Hashtable<_Key, std::pair<const _Key, _Val>, _Alloc, std::__detail::_Select1st, _Pred, _Hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<std::__not_<std::__and_<std::__is_fast_hash<_Hash>, std::__is_nothrow_invocable<const _Hash&, const _Key&> > >::value, false, true> >::value_type>, size_type, const hasher&, const allocator_type&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >; typename std::_Hashtable<_Key, std::pair<const _Key, _Val>, _Alloc, std::__detail::_Select1st, _Pred, _Hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<std::__not_<std::__and_<std::__is_fast_hash<_Hash>, std::__is_nothrow_invocable<const _Hash&, const _Key&> > >::value, false, true> >::value_type = std::pair<const int, int>; size_type = long unsigned int; hasher = std::hash<int>; allocator_type = std::allocator<std::pair<const int, int> >]'
  271 |       unordered_map(initializer_list<value_type> __l,
      |       ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:271:7: note:   candidate expects 4 arguments, 1 provided
/usr/include/c++/14/bits/unordered_map.h:265:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(std::initializer_list<typename std::_Hashtable<_Key, std::pair<const _Key, _Val>, _Alloc, std::__detail::_Select1st, _Pred, _Hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<std::__not_<std::__and_<std::__is_fast_hash<_Hash>, std::__is_nothrow_invocable<const _Hash&, const _Key&> > >::value, false, true> >::value_type>, size_type, const allocator_type&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >; typename std::_Hashtable<_Key, std::pair<const _Key, _Val>, _Alloc, std::__detail::_Select1st, _Pred, _Hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<std::__not_<std::__and_<std::__is_fast_hash<_Hash>, std::__is_nothrow_invocable<const _Hash&, const _Key&> > >::value, false, true> >::value_type = std::pair<const int, int>; size_type = long unsigned int; allocator_type = std::allocator<std::pair<const int, int> >]'
  265 |       unordered_map(initializer_list<value_type> __l,
      |       ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:265:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/unordered_map.h:246:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(size_type, const hasher&, const allocator_type&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >; size_type = long unsigned int; hasher = std::hash<int>; allocator_type = std::allocator<std::pair<const int, int> >]'
  246 |       unordered_map(size_type __n, const hasher& __hf,
      |       ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:246:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/unordered_map.h:242:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(size_type, const allocator_type&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >; size_type = long unsigned int; allocator_type = std::allocator<std::pair<const int, int> >]'
  242 |       unordered_map(size_type __n, const allocator_type& __a)
      |       ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:242:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/unordered_map.h:234:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(std::initializer_list<typename std::_Hashtable<_Key, std::pair<const _Key, _Val>, _Alloc, std::__detail::_Select1st, _Pred, _Hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<std::__not_<std::__and_<std::__is_fast_hash<_Hash>, std::__is_nothrow_invocable<const _Hash&, const _Key&> > >::value, false, true> >::value_type>, size_type, const hasher&, const key_equal&, const allocator_type&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >; typename std::_Hashtable<_Key, std::pair<const _Key, _Val>, _Alloc, std::__detail::_Select1st, _Pred, _Hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<std::__not_<std::__and_<std::__is_fast_hash<_Hash>, std::__is_nothrow_invocable<const _Hash&, const _Key&> > >::value, false, true> >::value_type = std::pair<const int, int>; size_type = long unsigned int; hasher = std::hash<int>; key_equal = std::equal_to<int>; allocator_type = std::allocator<std::pair<const int, int> >]'
  234 |       unordered_map(initializer_list<value_type> __l,
      |       ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:234:50: note:   no known conversion for argument 1 from 'std::map<int, int>' to 'std::initializer_list<std::pair<const int, int> >'
  234 |       unordered_map(initializer_list<value_type> __l,
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/unordered_map.h:217:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&&, const allocator_type&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >; allocator_type = std::allocator<std::pair<const int, int> >]'
  217 |       unordered_map(unordered_map&& __umap,
      |       ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:217:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/unordered_map.h:207:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(const std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&, const allocator_type&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >; allocator_type = std::allocator<std::pair<const int, int> >]'
  207 |       unordered_map(const unordered_map& __umap,
      |       ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:207:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/unordered_map.h:198:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(const allocator_type&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >; allocator_type = std::allocator<std::pair<const int, int> >]'
  198 |       unordered_map(const allocator_type& __a)
      |       ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:198:43: note:   no known conversion for argument 1 from 'std::map<int, int>' to 'const std::unordered_map<int, int>::allocator_type&' {aka 'const std::allocator<std::pair<const int, int> >&'}
  198 |       unordered_map(const allocator_type& __a)
      |                     ~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/unordered_map.h:191:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&&) [with _Key = int; _Tp = int; _Hash = std::ha