Problem:
Score : 600 points

Problem Statement

Takahashi has N cards. The i-th of these cards has an integer A_i written on it.

Takahashi will choose an integer K, and then repeat the following operation some number of times:

Choose exactly K cards such that the integers written on them are all different, and eat those cards. (The eaten cards disappear.)

For each K = 1,2, \ldots, N, find the maximum number of times Takahashi can do the operation.

Constraints

1 \le N \le 3 \times 10^5

1 \le A_i \le N

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 \ldots A_N

Output

Print N integers.
The t-th (1 \le t \le N) of them should be the answer for the case K=t.

Sample Input 1

3
2 1 2

Sample Output 1

3
1
0

For K = 1, we can do the operation as follows:

Choose the first card to eat.

Choose the second card to eat.

Choose the third card to eat.

For K = 2, we can do the operation as follows:

Choose the first and second cards to eat.

For K = 3, we cannot do the operation at all. Note that we cannot choose the first and third cards at the same time.

Sample Input 2

5
1 2 3 4 5

Sample Output 2

5
2
1
1
1

Sample Input 3

4
1 3 3 3

Sample Output 3

4
1
0
0

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<bits/stdc++.h>

using namespace std;

long long arr[300005],pre[300005],idx[300005],ans[300005];

bool ok(long long n,long long x,long long val,long long tail)
{
    if(x>=n)return true;
    long long y;
    if(x==0)y=0;else y=pre[x-1];
    if((n-x)*val<=(pre[n-1]-y)+tail)return true;
    return false;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    memset(arr,0,sizeof(arr));
    long long n,m,i,j,x,lo,hi,mid,tail;
    cin>>n;m=n;
    for(i=0;i<n;i++){cin>>x;arr[x]++;}
    n = 300002;
    sort(arr,arr+n);reverse(arr,arr+n);
    for(i=300001;i>=arr[0];i--)idx[i]=0;
    j=1;
    for(i=arr[0]-1;i>0;i--){
        idx[i] = min(j,m-1);
        while(j<n-1 && i == arr[j])j++;
    }
    //for(i=arr[0];i>0;i--)cout<<idx[i]<<endl;
    pre[0] = arr[0];
    for(i=1;i<n;i++)pre[i]=pre[i-1]+arr[i];
    for(i=0;i<m;i++){
        tail = pre[m]-pre[i];
        lo = arr[i];hi = 300000;ans[i]=0;
        while(lo<=hi){
            mid=(lo+hi)/2;
            x = idx[mid];
            if(ok(i+1,x,mid,tail)){ans[i] = mid;lo=mid+1;}
            else hi=mid-1;
        }
    }
    for(i=0;i<m;i++)cout<<ans[i]<<endl;
	return 0;
}