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



Sample input:
3
2 1 2


Sample output:
3
1
0

Submission status: Time Limit Exceeded

Solution code:
# F - Distinct Numbers
def Distinct(N, A):
    ans = [0] * (N+1)
    ans[1] = N

    uniq = sorted(set(A))
    uniq_num = len(uniq)

    freq = [0] * (N+1)
    for i in uniq:
        freq[i] = A.count(i)

    for i in range(2, N+1):
        if i > uniq_num: break
        cnt = 0
        arr = freq
        while True:
            arr = sorted(arr, reverse=True)
            tmp = arr[i-1]
            if tmp > 0:
                cnt += tmp
                for j in range(i): arr[j] -= tmp
            else:
                break
        ans[i] = cnt

    for i in range(1, N+1):
        print(ans[i])

N = int(input())
A = list(map(int, input().split()))
Distinct(N, A)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int,input().split()))

B = [0 for _ in range(N)]
for i in A:
    B[i-1] += 1

for i in range(N):
    ans = 0
    C = B
    C = sorted(C, reverse = True)
    while C[i] != 0:
       
        for j in range(i+1):
               C[j] -= 1
        C = sorted(C, reverse = True)
        ans += 1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int,input().split()))

B = [0 for _ in range(N)]
for i in A:
    B[i-1] += 1
B = tuple(sorted(B, reverse = True))

for i in range(N):
    ans = 0
    C = list(B)
    while C[i] != 0:
        for j in range(i+1):
            C[j] -= 1
        C = sorted(C, reverse = True)
        ans += 1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
 
#input
N = int(input())
A = list(map(int, input().split()))

from collections import Counter
import numpy as np
 
l = Counter(A).most_common()
l = [b for a, b in l]
l = np.array(l)

maximum_operation = [0] * N
for K in range(len(l)):
    l = Counter(A).most_common()
    l = [b for a, b in l]
    l = np.array(l)
    while l[K] > 0:
        l[0:K+1] -= 1
        l = np.sort(l, kind = "quicksort")[::-1]
        maximum_operation[K] += 1
 
for m in maximum_operation:
    print(m)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=list(map(int, input().split()))

B3b = [A.count(b) for b in set(A)]   #B数字の数
B3b.sort()

for k in range(1,N+1):
    B3 = B3b.copy()
    count = 0
    if len(B3)<k :
        print(0)
    else:
        while len(B3)>=k:
            n = len(B3)
            count += 1
            for d in range(n-1, n-k-1, -1):
                B3[d] -= 1
                if B3[d]== 0:
                    del(B3[d])
            if k > 1 and n-k < len(B3):
                if B3[n-k-1]>B3[n-k]:
                    B3.sort()
        print(count)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=list(map(int, input().split()))

B3b = [A.count(b) for b in set(A)]   #B数字の数
B3b.sort(reverse=True)

for k in range(1,N+1):
    B3 = B3b.copy()
    count = 0
    if len(B3)<k :
        print(0)
    else:
        while len(B3)>=k:
            count += 1
            for d in range(k-1, -1, -1):
                B3[d] -= 1
                if B3[d]== 0:
                    del(B3[d])
            if k > 1 and k < len(B3):
                if B3[k-1]<B3[k]:
                    B3.sort(reverse=True)
        print(count)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N=int(input())
A=list(map(int, input().split()))

B4 = np.array([A.count(b) for b in set(A)])   #B数字の数
B3b = np.sort(B4)[::-1]

for k in range(1,N+1):
    B3 = B3b.copy()
    count = 0
    if B3.size < k :
        print(0)
    else:
        while B3.size>=k:
            count += 1
            for d in range(k-1,-1,-1):
                B3[d] -= 1
                if B3[d] == 0:
                    B3 = np.delete(B3,d)
            if k > 1 and k < len(B3):
                if B3[k-1]<B3[k]:
                    B3=np.sort(B3)[::-1]
        print(count)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=list(map(int, input().split()))

B3b = [A.count(b) for b in set(A)]   #B数字の数
B3b.sort(reverse=True)

for k in range(1,N+1):
    B3 = B3b.copy()
    count = 0
    if len(B3)<k :
        print(0)
    else:
        while len(B3)>=k:
            count += 1
            for d in range(0,k):
                B3[d] -= 1
            while 0 in B3[:k]:
                B3.remove(0)
            if k > 1 and k < len(B3):
                if B3[k-1]<B3[k]:
                    B3.sort(reverse=True)
        print(count)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=list(map(int, input().split()))

B3b = [A.count(b) for b in set(A)]
B3b.sort(reverse=True)

for k in range(1,N+1):
    B3 = B3b.copy()
    count = 0
    if len(B3)<k :
        print(0)
    else:
        while len(B3)>=k:
            count += 1
            dmax = k
            d = 0
            while d < dmax:
                B3[d] -= 1
                if B3[d]== 0:
                    del(B3[d])
                    d -= 1
                    dmax -= 1
                d += 1
            if dmax > 1 and dmax < len(B3):
                if B3[dmax-1]<B3[dmax]:
                    B3.sort(reverse=True)
        print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
 
#input
N = int(input())
A = list(map(int, input().split()))

from collections import Counter
import numpy as np
 
l = Counter(A).most_common()
l = [b for a, b in l]
l = np.array(l)

maximum_operation = [0] * N
for K in range(len(l)):
    l = Counter(A).most_common()
    l = [b for a, b in l]
    l = np.array(l)
    while l[K] > 0:
        l[0:K+1] -= 1
        l = np.sort(l)[::-1]
        maximum_operation[K] += 1
 
for m in maximum_operation:
    print(m)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
 
#input
N = int(input())
A = list(map(int, input().split()))
 
#output
from collections import Counter
 
l = Counter(A).most_common()
l = [b for a, b in l]
 
maximum_operation = [0] * N
for K in range(len(l)):
    l = Counter(A).most_common()
    l = [b for a, b in l]
    while l[K] > 0:
        l = [p-1 for i, p in enumerate(l) if i < K+1] + [p for i, p in enumerate(l) if i >= K+1]
        l.sort(reverse = True)
        maximum_operation[K] += 1
 
for m in maximum_operation:
    print(m)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N=int(raw_input())
AN=map(int, raw_input().split())
BN=[0 for i in xrange(N)]
for i in AN:
    BN[i-1] += 1
BN=[i for i in BN if i > 0]
BN.sort(reverse=True)

for K in xrange(1, N+1):
    x = np.zeros(K)
    for i in BN:
        x[x.argmin()] += i

    print (int(x.min()))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N=int(input())
AN=map(int, input().split())
BN=[0 for i in range(N)]
for i in AN:
    BN[i-1] += 1
BN=[i for i in BN if i > 0]
BN.sort(reverse=True)

for K in range(1, N+1):
    x = np.zeros(K)
    for i in BN:
        x[x.argmin()] += i

    print (int(x.min()))

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
 
#input
N = int(input())
A = list(map(int, input().split()))
 
#output
from collections import Counter
 
l = Counter(A).most_common()
l = [b for a, b in l]
 
maximum_operation = [0] * N
for K in range(len(l)):
    l = Counter(A).most_common()
    l = [b for a, b in l]
    while l[K] > 0:
        for i in range(K+1):
            l[i] -= 1
        l.sort(reverse = True)
        maximum_operation[K] += 1
 
for m in maximum_operation:
    print(m)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline

#input
N = int(input())
A = list(map(int, input().split()))

#output
from collections import Counter

l = Counter(A).most_common()
l = [b for a, b in l]

maximum_operation = [0] * N
for K in range(len(l)):
    l = Counter(A).most_common()
    l = [b for a, b in l]
    while l[K] > 0:
        for i in range(K+1):
            l[i] -= 1
        l.sort(reverse = True)
        maximum_operation[K] += 1

for m in maximum_operation:
    print(m)

Submission status: Time Limit Exceeded

Solution code:
import copy

N=int(input())
A=list(map(int, input().split()))

Aset = set(A)
B = list(Aset)
B2b = [[b,A.count(b)] for b in B]   #各数字,その数字の数
B2b.sort(key=lambda b2: b2[1], reverse=True)

for k in range(1,N+1):
    B2 = copy.deepcopy(B2b)
    count = 0
    if len(B2)<k :
        print(0)
    else:
        while len(B2)>=k:
            count += 1
            dmax = k
            d = 0
            while d < dmax:
                B2[d][1] -= 1
                if B2[d][1]== 0:
                    del(B2[d])
                    d -= 1
                    dmax -= 1
                d += 1
            if dmax > 1 and dmax < len(B2):
                if B2[dmax-1][1]<B2[dmax][1]:
                    B2.sort(key=lambda b2: b2[1], reverse=True)
        print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
 
#input
N = int(input())
A = list(map(int, input().split()))
 
#output
from collections import Counter
from operator import itemgetter
 
l = Counter(A).most_common()
l = [[a, b] for a, b in l]
 
maximum_operation = [0] * N
for K in range(len(l)):
    l = Counter(A).most_common()
    l = [[a, b] for a, b in l]
    while l[K][1] > 0:
        for i in range(K+1):
            l[i][1] -= 1
        l.sort(key = itemgetter(1), reverse = True)
        maximum_operation[K] += 1
 
for m in maximum_operation:
    print(m)

Submission status: Time Limit Exceeded

Solution code:
import copy

N=int(input())
A=list(map(int, input().split()))

Aset = set(A)
B = list(Aset)
B2b = [[b,A.count(b)] for b in B]   #各数字,その数字の数
B2b.sort(key=lambda b2: b2[1], reverse=True)

for k in range(1,N+1):
    B2 = copy.deepcopy(B2b)
    count = 0
    if len(B2)<k :
        print(0)
    else:
        while len(B2)>=k:
            count += 1
            dmax = k
            d = 0
            while d < dmax:
                B2[d][1] -= 1
                if B2[d][1]== 0:
                    del(B2[d])
                    d -= 1
                    dmax -= 1
                d += 1
            B2.sort(key=lambda b2: b2[1], reverse=True)
        print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline

#input
N = int(input())
A = list(map(int, input().split()))
 
#output
from collections import Counter
from operator import itemgetter
l = Counter(A).most_common()
 
maximum_operation = [0] * N
for K in range(len(l)):
    l = Counter(A).most_common()
    while l[K][1] > 0:
        for i in range(K+1):
            l[i] = (l[i][0], l[i][1]-1)
        l.sort(key=itemgetter(1), reverse = True)
        maximum_operation[K] += 1
 
for m in maximum_operation:
    print(m)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline

#input
N = int(input())
A = list(map(int, input().split()))
 
#output
from collections import Counter
from operator import itemgetter
l = Counter(A).most_common()
 
maximum_operation = [0] * N
for K in range(len(l)):
    l = Counter(A).most_common()
    while l[K][1] > 0:
        for i in range(K+1):
            l[i] = (l[i][0], l[i][1]-1)
        l.sort(key=itemgetter(1), reverse = True)
        maximum_operation[K] += 1
 
for m in maximum_operation:
    print(m)

Submission status: Time Limit Exceeded

Solution code:
#input
N = int(input())
A = list(map(int, input().split()))

#output
from collections import Counter
l = Counter(A).most_common()

maximum_operation = [0] * N
for K in range(len(l)):
    l = Counter(A).most_common()
    while l[K][1] > 0:
        for i in range(K+1):
            l[i] = (l[i][0], l[i][1]-1)
        l.sort(key = lambda x:x[1], reverse = True)
        maximum_operation[K] += 1

for m in maximum_operation:
    print(m)

Submission status: Time Limit Exceeded

Solution code:
#input
N = int(input())
A = list(map(int, input().split()))

#output
from collections import Counter
l = Counter(A)
l = l.most_common()

maximum_operation = [0] * N
for K in range(len(l)):
    l = Counter(A)
    l = l.most_common()
    while l[K][1] > 0:
        for i in range(K+1):
            l[i] = (l[i][0], l[i][1]-1)
        l.sort(key = lambda x:x[1], reverse = True)
        maximum_operation[K] += 1

for m in maximum_operation:
    print(m)

Submission status: Time Limit Exceeded

Solution code:
#input
N = int(input())
A = list(map(int, input().split()))

#output
from collections import Counter
l = Counter(A)
l = l.most_common()

maximum_operation = [0] * N
for K in range(len(l)):
    l = Counter(A)
    l = l.most_common()
    while l[K][1] > 0:
        for i in range(K+1):
            l[i] = (l[i][0], l[i][1]-1)
        l = sorted(l, key = lambda x:x[1], reverse = True)
        maximum_operation[K] += 1

for m in maximum_operation:
    print(m)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
AN=map(int, input().split())
BN=[0 for i in range(N)]
for i in AN:
    BN[i-1] += 1
BN=[i for i in BN if i > 0]
BN.sort(reverse=True)

for K in range(1, N+1):
    b = BN[:]
    c = 0
    while True:
        if len(b) < K:
            break
        b.sort(reverse=True)
        c += b[K-1]
        for i in range(K):
            b[i] -= b[K-1]
        b.pop(K-1)
    print (c)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
AN=map(int, input().split())
BN=[0 for i in range(N)]
for i in AN:
    BN[i-1] += 1

for K in range(1, N+1):
    b = BN[:]
    c = 0
    while True:
        if len(b) < K:
            break
        b.sort(reverse=True)
        c += b[K-1]
        for i in range(K):
            b[i] -= b[K-1]
        b.pop(K-1)
    print (c)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=[]
k=1
for i in range(n-1):
    if a[i]==a[i+1]:
        k+=1
    else:
        b.append(k)
        k=1
b.append(k)
b.sort(reverse=True)
print(n)
l=len(b)
for i in range(2,n+1):
    if l<i:
        print(0)
    else:
        c=b.copy()
        ans=0
        for j in range(n+1):
            if c[i-1]!=0:
                ans += c[i-1]
                for m in range(i):
                    c[m]-=c[i-1]
                c.sort(reverse=True)
            else:
                break
        print(ans)

Submission status: Time Limit Exceeded

Solution code:
from copy import copy
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=[]
k=1
for i in range(n-1):
    if a[i]==a[i+1]:
        k+=1
    else:
        b.append(k)
        k=1
b.append(k)
b.sort(reverse=True)
print(n)
l=len(b)
for i in range(2,n+1):
    if l<i:
        print(0)
    else:
        c=copy(b)
        ans=0
        for j in range(n+1):
            if c[i-1]!=0:
                ans += c[i-1]
                for m in range(i):
                    c[m]-=c[i-1]
                c.sort(reverse=True)
            else:
                break
        print(ans)

Submission status: Time Limit Exceeded

Solution code:
def count_unique_samples(k, arr):
    res = 0
    not_stop = True
    while not_stop:
        for i in range(k):
            if arr[i] > 0:
                arr[i] -= 1
            else:
                not_stop = False
                break
        if not_stop:
            res += 1
            arr.sort(reverse=True)
    return res


def solve():
    n = int(input())
    al = map(int, input().split())

    cnt = [0] * (n + 1)

    for a in al:
        cnt[a] += 1

    cnt.sort(reverse=True)

    unique_num = len(cnt) - cnt.count(0)

    print(n)    

    for k in range(2, n+1):
        if k > unique_num:
            print(0)
            continue
        if k > 2*unique_num:
            print(1)
            continue
        print(count_unique_samples(k, cnt.copy()))
        
        
if __name__ == "__main__":
    solve()

Submission status: Time Limit Exceeded

Solution code:
def count_unique_samples(k, arr):
    res = 0
    not_stop = True
    while not_stop:
        for i in range(k):
            if arr[i] > 0:
                arr[i] -= 1
            else:
                not_stop = False
                break
        if not_stop:
            res += 1
            arr.sort(reverse=True)
    return res


def solve():
    n = int(input())
    al = map(int, input().split())

    cnt = [0] * (n + 1)

    for a in al:
        cnt[a] += 1

    cnt.sort(reverse=True)

    unique_num = len(cnt) - cnt.count(0)

    print(n)    

    for k in range(2, n+1):
        print(count_unique_samples(k, cnt.copy()))
        
        
if __name__ == "__main__":
    solve()

Submission status: Time Limit Exceeded

Solution code:
#numpyで数えていたのを変更
N=int(input())
A=list(map(int,input().split()))

c = [0] * (N + 1)
Dx = [0] * (N + 1)
for a in A:
    c[a] += 1
    Dx[c[a]] += 1

Sx=[0]#初項は0
for j in range(1,N+1):
    Sx.append(Sx[j-1]+Dx[j])

#Sxが作れたので、xに関して二分探索をする
for k in range(1,N+1):
    x_min=0
    x_max=N+1
    while x_max>x_min+1:
        x_mid=(x_max+x_min)//2
        if Sx[x_mid]>=k*x_mid:
            x_min=x_mid
        else:
            x_max=x_mid
    print(x_min)

Submission status: Time Limit Exceeded

Solution code:
#numpyで数えていたのを変更
N=int(input())
A=list(map(int,input().split()))
from collections import Counter
c=Counter(A)
c_all_ones=Counter()
for key in c.keys():
    c_all_ones[key]=1
Dx=[0]
for i in range(1,N+1):
    Dx.append(len(c))
    c.subtract(c_all_ones)
    c=+c #0以下を削除

Sx=[0]#初項は0
for j in range(1,N+1):
    Sx.append(Sx[j-1]+Dx[j])

#Sxが作れたので、xに関して二分探索をする
for k in range(1,N+1):
    x_min=0
    x_max=N+1
    while x_max>x_min+1:
        x_mid=(x_max+x_min)//2
        if Sx[x_mid]>=k*x_mid:
            x_min=x_mid
        else:
            x_max=x_mid
    print(x_min)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=list(map(int,input().split()))
from collections import Counter
import numpy as np
c=Counter(A)
c_np=np.array(c.most_common())#リストにいったん変換しないと。
#Sx=Σmin(ci,x)を求める
#SxもDxもNまで作れば十分
Dx=[0] #D_0は使わない。インデックスの調整用
for i in range(1,N+1):
    target=c_np[c_np[:,1]>=i]
    Dx.append( len(target) )
#i以上の部分の個数はこれで決まり
Sx=[0]#初項は0
for j in range(1,N+1):
    Sx.append(Sx[j-1]+Dx[j])

#Sxが作れたので、xに関して二分探索をする
for k in range(1,N+1):
    x_min=0
    x_max=N+1
    while x_max>x_min+1:
        x_mid=(x_max+x_min)//2
        if Sx[x_mid]>=k*x_mid:
            x_min=x_mid
        else:
            x_max=x_mid
    print(x_min)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=list(map(int,input().split()))
from collections import Counter
for k in range(1,N+1):
    c=Counter(A)
    ans=0
    if len(c)<k:
        print(0)
    else:
        while True:
            for (i,j) in c.most_common()[:k]:
                c[i]-=1
            if c.most_common()[-1][1]<0:
                break
            ans+=1
        print(ans)

Submission status: Time Limit Exceeded

Solution code:
import bisect as b
n = int(input())

d = [0]*n
for el in map(int, input().split()):
    d[el-1] += 1

d.sort()

for k in range(1, n+1):
    l = 0
    r = n//k + 1
    while(l+1 < r):
        c = (l+r)//2
        i = b.bisect_left(d, c)
        total = sum(d[:i]) + c * (n - i)
        if total >= k * c:
            l = c
        else:
            r = c
    print(l)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=[int(j) for j in input().split()]
from collections import Counter
c=Counter(a)
l=c.most_common()
ll=[]
for i,j in l:
    ll.append(-j)

import heapq
import copy
for k in range(1,1+n):
    if k==1:
        print(n)
    else:
        ans=0
        q=copy.deepcopy(ll)
        heapq.heapify(q)
        while True:
            if len(q)<k:
                break
            t=[]
            for i in range(k):
                t.append(-heapq.heappop(q))
            m=min(t)
            ans+=m
            for i in t:
                if i-m!=0:
                    heapq.heappush(q,-(i-m))
        print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools
import collections
N = int(input())
A = [int(_) for _ in input().split()]
c = sorted(collections.Counter(A).values())
acc = list(itertools.accumulate([0] + c))
n = len(acc) - 1
for i in range(1, n + 1):
    r = 0
    j = 0
    while i - j > 0:
        if (i - j) * c[-1 - j] <= acc[-1 - j]:
            r = acc[-1 - j] // (i - j)
            break
        else:
            j += 1
    print(r)
for _ in range(N - n):
    print(0)

Submission status: Time Limit Exceeded

Solution code:
import collections
import bisect
n=int(input())
a=collections.Counter(map(int,input().split()))
a=list(a.values())
a.sort()
b=[0]*len(a)
b[0]=a[0]
for i in range(len(a)-1):
    b[i+1]=b[i]+a[i+1]
s=sum(a)
ans=[i for i in range(0,n+1)]
ans=ans[::-1]
for t in range(1,n+1):
    for A in ans:
        z=bisect.bisect_right(a,A)
        if A*t<=(b[z-1] if z>=1 else 0)+A*(len(b)-z):
            print(A)
            break

Submission status: Time Limit Exceeded

Solution code:
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

# 解説AC
# https://twitter.com/maspy_stars/status/1185552225474498560
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))


def test(k):
    bc = np.bincount(A)
    bc.sort()
    bc = bc[np.searchsorted(bc, 1):]
    bc = bc[::-1]
    ret = 0

    while len(bc) >= k:
        bc[:k] -= 1
        bc.sort()
        bc = bc[np.searchsorted(bc, 1):]
        bc = bc[::-1]
        ret += 1
    return ret


C = np.bincount(A)
C.sort()


def solve(k):
    cnt = N // k
    if C[-1] <= cnt:
        # 全部取れるとしていい
        # 最後に2つ以上余ると max_c <= cnt に矛盾する
        return cnt

    S = N
    i = 1
    while i < k:
        # 最大値は毎回取ることにしてもう見ない
        S -= C[-i]
        cnt = S // (k - i)
        max_c = C[-i - 1]
        if max_c <= cnt:
            return cnt
        i += 1
    return 0


ans = [0] * N
for k in reversed(range(1, N + 1)):
    ans[k - 1] = solve(k)
print(*ans, sep='\n')

Submission status: Time Limit Exceeded

Solution code:
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

# 解説AC
# https://twitter.com/maspy_stars/status/1185552225474498560
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))


def test(k):
    bc = np.bincount(A)
    bc.sort()
    bc = bc[np.searchsorted(bc, 1):]
    bc = bc[::-1]
    ret = 0

    while len(bc) >= k:
        bc[:k] -= 1
        bc.sort()
        bc = bc[np.searchsorted(bc, 1):]
        bc = bc[::-1]
        ret += 1
    return ret


C = np.bincount(A)
C.sort()


def solve(k):
    cnt = N // k
    if C[-1] <= cnt:
        # 全部取れるとしていい
        # 最後に2つ以上余ると max_c <= cnt に矛盾する
        return cnt

    S = N
    i = 1
    while i < k:
        # 最大値は毎回取ることにしてもう見ない
        S -= C[-i]
        cnt = S // (k - i)
        max_c = C[-i - 1]
        if max_c <= cnt:
            return cnt
        i += 1
    return 0


ans = [0] * N
for k in reversed(range(1, N + 1)):
    ans[k - 1] = test(k)
print(*ans, sep='\n')

Submission status: Time Limit Exceeded

Solution code:
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))


def test(k):
    bc = np.bincount(A)
    bc.sort()
    bc = bc[np.searchsorted(bc, 1):]
    bc = bc[::-1]
    ret = 0

    while len(bc) >= k:
        bc[:k] -= 1
        bc.sort()
        bc = bc[np.searchsorted(bc, 1):]
        bc = bc[::-1]
        ret += 1
    return ret


ans = [0] * N
for k in reversed(range(1, N + 1)):
    ans[k - 1] = test(k)
print(*ans, sep='\n')

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int,input().split()))
c,d,s = [0 for _ in range(n+1)],[0 for _ in range(n+1)],[0 for _ in range(n+1)]
for i in A:
    c[i] += 1
    d[c[i]] += 1
for i in range(1,n+1):
    s[i] = s[i-1]+d[i]
for i in range(1,n+1):
    l,u = 0,n+1
    while u-l > 1:
        mid = (l+u)//2
        if s[mid] >= i*mid:
            l = mid
        else:
            u = mid
    print(l)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
A = list(map(int,input().split()))
c,d,s = [0 for _ in range(n+1)],[0 for _ in range(n+1)],[0 for _ in range(n+1)]
for i in A:
    c[i] += 1
    d[c[i]] += 1
for i in range(1,n+1):
    s[i] = s[i-1]+d[i]
for i in range(1,n+1):
    l,u = 0,n+1
    while u-l > 1:
        mid = (l+u)//2
        if s[mid] >= i*mid:
            l = mid
        else:
            u = mid
    print(l)

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import Counter
from bisect import bisect_left

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

class BitSum:
    def __init__(self, n):
        self.n = n
        self.table = [0] * (n + 1)

    def update(self, i, x):
        i += 1
        while i <= self.n:
            self.table[i] += x
            i += i & -i

    def sum(self, i):
        i += 1
        res = 0
        while i > 0:
            res += self.table[i]
            i -= i & -i
        return res

def main():
    n = int(input())
    aa = list(map(int, input().split()))
    aa = list(Counter(aa).values())
    aa.sort()
    bit = BitSum(len(aa))
    for i, a in enumerate(aa):
        bit.update(i, a)
    # print(aa)
    l = n + 1
    pi=len(aa)
    for k in range(1, n + 1):
        r = l + 1
        l = 0
        while l + 1 < r:
            m = (l + r) // 2
            i = bisect_left(aa[:pi + 1], m)
            s = bit.sum(i - 1) + m * (len(aa) - i)
            if s >= m * k:
                l = m
            else:
                r = m
        pi = i
        print(l)

main()

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import Counter
from bisect import bisect_left

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

class BitSum:
    def __init__(self, n):
        self.n = n
        self.table = [0] * (n + 1)

    def update(self, i, x):
        i += 1
        while i <= self.n:
            self.table[i] += x
            i += i & -i

    def sum(self, i):
        i += 1
        res = 0
        while i > 0:
            res += self.table[i]
            i -= i & -i
        return res

def main():
    n = int(input())
    aa = list(map(int, input().split()))
    aa = list(Counter(aa).values())
    aa.sort()
    bit = BitSum(len(aa))
    for i, a in enumerate(aa):
        bit.update(i, a)
    # print(aa)
    l = n + 1
    for k in range(1, n + 1):
        r = l + 1
        l = 0
        while l + 1 < r:
            m = (l + r) // 2
            i = bisect_left(aa, m)
            s = bit.sum(i - 1) + m * (len(aa) - i)
            if s >= m * k:
                l = m
            else:
                r = m
        print(l)

main()

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import Counter
from bisect import bisect_left

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

class BitSum:
    def __init__(self, n):
        self.n = n
        self.table = [0] * (n + 1)

    def update(self, i, x):
        i += 1
        while i <= self.n:
            self.table[i] += x
            i += i & -i

    def sum(self, i):
        i += 1
        res = 0
        while i > 0:
            res += self.table[i]
            i -= i & -i
        return res

def main():
    n = int(input())
    aa = list(map(int, input().split()))
    aa = list(Counter(aa).values())
    aa.sort()
    bit = BitSum(len(aa))
    for i, a in enumerate(aa):
        bit.update(i, a)
    # print(aa)
    for k in range(1, n + 1):
        l = 0
        r = n // k + 2
        while l + 1 < r:
            m = (l + r) // 2
            i = bisect_left(aa, m)
            s = bit.sum(i - 1) + m * (len(aa) - i)
            if s >= m * k:
                l = m
            else:
                r = m
        print(l)

main()

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline

from collections import Counter
from copy import deepcopy
from heapq import heapify, heappush, heappop


def main():
    n = int(input())
    a = list(map(int, input().split()))

    #n = 3 * 10 ** 5
    #a = list(range(1, n + 1))

    c = Counter(a)
    c = list(c.values())
    heapify(c)

    k_mx = len(c)

    for k in range(1, n + 1):
        if k > k_mx:
            print(0)
            continue

        cp = deepcopy(c)

        for _ in range(k_mx - k):
            cnt = heappop(cp)
            while cnt:
                mn = heappop(cp)
                cnt -= 1
                heappush(cp, mn + 1)

        ans = heappop(cp)
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import Counter
from bisect import bisect_left

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

class BitSum:
    def __init__(self, n):
        self.n = n
        self.table = [0] * (n + 1)

    def update(self, i, x):
        i += 1
        while i <= self.n:
            self.table[i] += x
            i += i & -i

    def sum(self, i):
        i += 1
        res = 0
        while i > 0:
            res += self.table[i]
            i -= i & -i
        return res

def main():
    n = int(input())
    aa = list(map(int, input().split()))
    aa = list(Counter(aa).values())
    aa.sort()
    bit = BitSum(len(aa))
    for i, a in enumerate(aa):
        bit.update(i, a)
    # print(aa)
    r0 = bit.sum(len(aa) - 1) + 1
    for k in range(1, n + 1):
        l = 0
        r = r0
        while l + 1 < r:
            m = (l + r) // 2
            i = bisect_left(aa, m)
            s = bit.sum(i - 1) + m * (len(aa) - i)
            if s >= m * k:
                l = m
            else:
                r = m
        print(l)

main()