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: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import collections

def solve(N: int, A: "List[int]"):
    counter = sorted(list(collections.Counter(A).values()),reverse=True)
    c_index = 0
    k=0
    for i in range(1,N+1):
        k+=1
        if len(counter)<i:
            print(0)
            continue
        while counter[c_index]*k > N and c_index<len(counter)-1:
            N-=counter[c_index]
            c_index+=1
            k-=1
        print(N//k)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

N = int(input())

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

dic = {}

for a in A:

    if a not in dic:
        dic[a] = 1
    else:
        dic[a] += 1

B = []
for i in dic:
    B.append(dic[i])

B.sort()

B_sub = B.copy()

for i in range(len(B)-1):
    B_sub[i+1] += B_sub[i] 

aind = N + 1
nind = len(B) - 1

#print (B,B_sub)

for i in range(N):

    i += 1

    while True:

        while nind > 0 and B[nind] > aind - 1:

          nind -= 1

        if i > len(B):
            print (0)
            break

        elif ((len(B) - 1) - nind ) * (aind-1) + B_sub[nind] >= (aind - 1) * i:
            print (aind - 1)
            break

        aind -= 1

Submission status: Accepted

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

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

from collections import Counter
from itertools import accumulate
import bisect

C=Counter(A)

LIST=sorted(C.values())
LEN=len(LIST)
SUM=[0]+list(accumulate(LIST))
MIN=0
MAX=SUM[-1]

for k in range(1,N+1):
    MIN=0
    while MIN!=MAX:
        mid=(MIN+MAX+1)//2
        x=bisect.bisect_right(LIST,mid)

        if SUM[x]+(LEN-x)*mid>=mid*k:
            MIN=mid
        else:
            MAX=mid-1

    print(MIN)

Submission status: Accepted

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

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

from collections import Counter
from itertools import accumulate
import bisect

C=Counter(A)

LIST=sorted(C.values())
LEN=len(LIST)
SUM=[0]+list(accumulate(LIST))
MIN=0
MAX=SUM[-1]

for k in range(1,N+1):
    MIN=0
    while MIN!=MAX:
        mid=(MIN+MAX+1)//2
        x=bisect.bisect_right(LIST,mid)

        if SUM[x]+(LEN-x)*mid>=mid*k:
            MIN=mid
        else:
            MAX=mid-1

    print(MIN)

Submission status: Accepted

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

num = [0 for _ in range(N)]
for a in A:
    num[a-1] += 1
num.sort()
cum = [0 for _ in range(N)]
cum[0] = num[0]
for i in range(1, N):
    cum[i] = cum[i-1] + num[i]

index = N - 1
ans = N
for k in range(1, N+1):
    while ans > 0:
        tmp_index = index
        while tmp_index >= 0 and num[tmp_index] > ans:
            tmp_index -= 1
        decided = N - tmp_index - 1
        rest_total = 0 if tmp_index < 0 else cum[tmp_index]
        if rest_total >= ans * (k - decided):
            index = tmp_index
            break
        ans -= 1
    print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7



n = I()
L = [(0, 0)] + sorted([(k, v) for k, v in Counter(Counter(LI()).values()).items()])
m = len(L)
acc = [0] * m
ret = 0
for j in range(m):
    k, v = L[j]
    ret += k * v
    acc[j] = ret


v_acc = [0] * m
ret = 0
for l in range(m - 1, -1, -1):
    ret += L[l][1]
    v_acc[l] = ret


v_acc += [0]



for i in range(1, n + 1):
    ok = 0
    ng = n // i + 1
    while ng > ok + 1:
        mid = (ng + ok) // 2
        lower_num = bisect_right(L, (mid, INF))
        if acc[lower_num - 1] + v_acc[lower_num] * mid >= i * mid:
            ok = mid
        else:
            ng = mid
    print(ok)

Submission status: Accepted

Solution code:
from collections import Counter
from bisect import bisect_left
from itertools import accumulate

# https://betrue12.hateblo.jp/entry/2019/10/20/001106

N = int(input())
A = list(map(int, input().split()))
a = list(Counter(A).values())
a.sort()
b = list(accumulate(a))
length = len(a)

for i in range(1, N + 1):
    if i == 1:
        print(b[-1])
    elif len(a) < i:
        print(0)
    else:
        n = b[-1] // i
        for j in reversed(range(1, n + 1)):
            t = bisect_left(a, j)
            if j * i <= b[t - 1] + (length - t) * j:
                print(j)
                break

Submission status: Accepted

Solution code:
from collections import Counter
from bisect import bisect_left
from itertools import accumulate

N = int(input())
A = list(map(int, input().split()))
a = list(Counter(A).values())
a.sort()
b = list(accumulate(a + [0]))
s = sum(a)
length = len(a)

for i in range(1, N + 1):
    if i == 1:
        print(s)
    elif len(a) < i:
        print(0)
    else:
        n = s // i
        for j in reversed(range(1, n + 1)):
            t = bisect_left(a, j)
            if j * i <= b[t - 1] + (length - t) * j:
                print(j)
                break

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = list(Counter(A).values())
D = [0] * (N+1)
for k, d in Counter(C).items():
    D[k] = d

ckd, cd = [0] * (N+1), [0] * (N+1)

for i in range(1,N+1):
    cd[i] = cd[i-1] + D[i]
    ckd[i] = ckd[i-1] + i*D[i]

INF = float('inf')
def f(x):
    if x:
        return (x*(cd[-1] - cd[x]) + ckd[x]) // x
    return INF

cur = N
v = f(cur)
for k in range(1,N+1):
    while k > v:
        cur -= 1
        v = f(cur)
    print(cur)

Submission status: Accepted

Solution code:
from collections import Counter
from itertools import accumulate

# from copy import deepcopy

n = int(input())
a = list(map(int, input().split()))
c = Counter(a)

# for k in range(1, n + 1):
#     cx = deepcopy(c)

#     count = 0

#     while k <= len(cx):
#         # print(cx)
#         mc = cx.most_common()
#         for key, _ in mc[:k]:
#             cx[key] -= 1
#             if cx[key] < 1:
#                 del cx[key]
#         count += 1

#     print(count)

cv = Counter(c.values())
max_take = max(cv.keys())

lx = list(accumulate(cv[i] for i in range(max_take + 1)))
rx = list(accumulate(cv[i] * i for i in range(max_take + 1)))
ax = [rx[i] + (lx[-1] - lx[i]) * i for i in range(max_take + 1)]


def bisec(l0, r0, predicate):
    l, r = l0, r0

    while abs(l - r) > 1:
        mid = (l + r) // 2
        if predicate(mid):
            r = mid
        else:
            l = mid

    return r


for k in range(1, n + 1):
    print(bisec(n + 1, 0, lambda x: x * k <= ax[min(x, max_take)]))

Submission status: Accepted

Solution code:
from bisect import bisect
n=int(input())
a=list(map(int,input().split()))
a.sort()
k=a[0]
data=[]
count=1
for i in range(1,n):
    if a[i]==k:
        count+=1
    else:
        k=a[i]
        data.append(count)
        count=1
data.append(count)
data.sort()
l=len(data)
lst=[]
for u in data:
    if lst:
        lst.append(u+lst[-1])
    else:
        lst.append(u)
li=[0]*(n+1)
for ans in range(1,n+1):
    i=bisect(data,ans)
    if i==0:
        j=ans*l
    else:
        j=lst[i-1]+ans*(l-i)
    k=j//ans
    li[k]=ans
z=0
for i in range(n):
    if li[n-i]==0:
        li[n-i]=z
    else:
        z=li[n-i]
for i in range(1,n+1):
    print(li[i])

Submission status: Accepted

Solution code:
import bisect
def main():

    N = int(input())
    A = list(map(int, input().split()))
    cntA = dict()
    for a in A:
        cntA[a] = cntA.get(a, 0) + 1

    cnt = dict()
    for a in cntA:
        cnt[cntA[a]] = cnt.get(cntA[a], 0) + 1

    sum1 = [0]
    for i in range(1, N+1):
        if i in cnt:
            sum1.append(sum1[-1]+ i * cnt[i])
        else:
            sum1.append(sum1[-1])

    sum2 = [0]
    for i in range(N, -1, -1):
        if i in cnt:
            sum2.append(sum2[-1]+cnt[i])
        else:
            sum2.append(sum2[-1])
    sum2 = sum2[::-1]

    vals = []
    for i in range(1, N+1):
        v = (sum1[i] + i * sum2[i+1]) // i
        vals.append(v)
    vals = vals[::-1]

    for i in range(1, N+1):
        j = bisect.bisect_left(vals, i)
        print(N-j)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#x個の列を取り出せる最大の長さf(x)を考える
#dの導入

import bisect
n = int(input())
a = list(map(int, input().split()))

c = [0]*(n+1)

for i in range(n):
    c[a[i]] += 1

d = [0]*(n+1)
for i in range(n+1):###
    d[c[i]] += 1

sum1 = 0
sum2 =sum(d)-d[0]
fx = []
for x in range(1,n+1):
    sum1 += x*d[x]
    sum2 -= d[x]
    fx.append((sum1+x*sum2)//x)
fx.sort()
for i in range(1,n+1):
    j = bisect.bisect_left(fx,i)###
    print(n-j)

Submission status: Accepted

Solution code:
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split()) 
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def f(k,p):
  return (c[p] >= k*p)

def ff(k,p):
  acc = n 
  for i in range(len(b)):
    if b[i]>p:
      acc -= b[i]-p 
    else:
      break
  return (acc >= k*p)

n = inn()
a = inl()
h = {}
for x in a:
  if x in h:
    h[x] += 1
  else:
    h[x] = 1
b = []
for x in h:
  b.append(h[x])
b.sort(reverse=True)

#ddprint(b)

c = [0]*(n+1)
for p in range(1,n+1):
  acc = n 
  for i in range(len(b)):
    if b[i]>p:
      acc -= b[i]-p 
    else:
      break
  c[p] = acc


for k in range(1,n+1):
  mn = 0
  mx = n//k + 1
  while mx > mn+1:
    mid = (mn+mx)//2
    if f(k,mid):
      mn = mid 
    else:
      mx = mid 
  print(mn)

Submission status: Accepted

Solution code:
from collections import Counter
from itertools import accumulate
from bisect import bisect_right
N = int(input())
As = list(map(int, input().split()))
ct = Counter(As)
ctm = [c[1] for c in ct.most_common()]
ctm.reverse()
L = len(ctm)
acc = [0] +  list(accumulate(ctm))

arr = [0]
for n in range(1, N+1):
  idx = bisect_right(ctm, n)
  arr.append(acc[idx] + n*(L-idx))

for n in range(1, N+1):
  f = 0
  t = N // n + 1
  while f + 1 < t:
    m = f + (t-f) // 2
    if arr[m] >= m*n:
      f = m
    else:
      t = m
  print(f)

Submission status: Accepted

Solution code:
from collections import Counter
from itertools import accumulate

def bisect(ng, ok, judge):
    while abs(ng-ok) > 1:
        m = (ng+ok)//2
        if judge(m):
            ok = m
        else:
            ng = m
    return ok

N = int(input())
A = Counter(Counter(map(int,input().split())).values())
m = max(A.keys())
nA = list(accumulate(A[c] for c in range(m+1)))
wA = list(accumulate(A[c]*c for c in range(m+1)))

A = [wA[i]+(nA[-1]-nA[i])*i for i in range(m+1)]
for k in range(1,N+1):
    print(bisect(N+1, 0, lambda x: x*k <= A[min(x,m)]))

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    d = defaultdict(lambda : 0)
    for i in a:
        d[i] += 1
    d = list(d.values())
    q = []
    for i in d:
        heappush(q,i)
    ans = []
    for k in range(n):
        if not q:
            break
        else:
            x = heappop(q)
            ans.append(x)
            while q and x:
                y = heappop(q)
                y += 1
                x -= 1
                heappush(q,y)
    for i in ans[::-1]+[0]*(n-len(ans)):
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
AA = inpl()
cnts = defaultdict(int)
ed = set()
for a in AA:
    cnts[a] += 1
    ed.add(a)

aa1 = [[i,0] for i in range(1,N+1)]
for e in ed:
    aa1[cnts[e]-1][1] += 1

aa2 = [0] # 種類数
aa3 = [0] # 実枚数
for t,n in aa1:
    aa2.append(aa2[-1] + n)
    aa3.append(aa3[-1] + n*t)

L = len(aa1)
tmpl_t = []
tmpl_c = []
for i,(t,n) in enumerate(aa1):
    tmp = n + aa3[i]//t
    tmp += aa2[-1] - aa2[i+1]
    tmpl_t.append(t)
    tmpl_c.append(tmp)
    # print(t,'回食べるとき，最大',tmp,'枚までいける')

tmpl_t.reverse()
tmpl_t.append(0)
tmpl_c.reverse()
# print(tmpl_t)
# print(tmpl_c)
ans = [0]*N
for i in range(1,N+1):
    idx = bisect.bisect_left(tmpl_c,i)
    if idx == 0:
        ans[i-1] = N//i
    else:
        ans[i-1] = tmpl_t[idx]

print('\n'.join(map(str,ans)))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

"""
・大きいKから見る
・a_N <= S//K：全て取り切れて、S//Kが解
・a_N > S/K：a_Nは常に選ぶとしてよい。K-1枚でa_{N-1}までのゲームに帰着
"""

from collections import Counter

N,*A = map(int,read().split())

counter = Counter(A)
C = list(counter.values())
C.sort()
S = sum(C)

answer = []
removed = 0
for K in range(1,N+1):
    rest = K - removed
    while C and C[-1] > S//rest:
        S -= C[-1]
        C.pop()
        removed += 1
        rest -= 1
    answer.append(S//rest)

print('\n'.join(map(str,answer)))

Submission status: Runtime Error

Solution code:
N = int(input())
A = sorted(list(map(int, input().split())))
S = []
f = -1
for a in A:
  if f != a:
    f = a
    S.append(1)
  else:
    S[-1] += 1
S.sort(reverse = True)
for K in range(1, N+1):
  ans = 0
  T = [s for s in S]
  while len(T) >= K:
    ans += T[K-1]
    for n in range(K):
      if T[n] > T[K-1]:
        T[n] -= T[K-1]
      else:
        T.pop(n)
  print(ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n = I()
a = LI()
c = list(Counter(a).items())
x = len(c)
H = []
for i,j in c:
    heappush(H,j)
for k in range(1,n+1):
    if k == 1:
        print(n)
        continue
    h = H.copy()
    x = len(h)
    if k > x:
        print(0)
        continue
    ans = 0
    while x >= k:
        ans += 1
        tmp = heappop(h)
        lst = []
        x -= 1
        for _ in range(k-1):
            s = heappop(h)
            s -= tmp
            if s == 0:
                x -= 1
                continue
            lst.append(s)
        for i in lst:
            heappush(h,i)
    print(ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n = I()
a = LI()
c = list(Counter(a).items())

x = len(c)
H = []
for i,j in c:
    heappush(H,j)
for k in range(1,n+1):
    if k == 1:
        print(n)
        continue
    if k > x:
        print(0)
        continue
    h = H.copy()
    ans = 0
    while len(h) >= k:
        ans += 1
        tmp = heappop(h)
        lst = []
        for _ in range(k-1):
            s = heappop(h)
            s -= tmp
            if s == 0:
                continue
            lst.append(s)
        for i in lst:
            heappush(h,i)
    print(ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n = I()
a = LI()
c = list(Counter(a).items())
x = len(c)
H = []
for i,j in c:
    heappush(H,-j)
for k in range(1,n+1):
    if k == 1:
        print(n)
        continue
    if k > x:
        print(0)
        continue
    h = H.copy()
    ans = 0
    while len(h) >= k:
        ans += 1
        tmp = heappop(h)
        tmp = -tmp
        lst = []
        for _ in range(k-1):
            s = heappop(h)  
            s = -s
            s -= tmp
            if s <= 0:
                continue
            lst.append(-s)
        for i in lst:
            heappush(h,i)
    print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
count = {}
for x in map(int, input().split()):
    count[x] = count.get(x, 0) + 1

a = sorted(count.values())
sums = a[:]
n = len(a)
for i in range(1, n):
    sums[i] += sums[i-1]
    
def check(k, x):
    pos = bisect.bisect_right(a, x)
    return (sums[pos-1] if pos-1 >= 0 else 0) + x * (n - pos) >= k * x

x = 0
res = []
for k in range(N, 0, -1):
    while check(k, x+1):
        x += 1
    res.append(x)
    
for x in res[::-1]:
    print(x)

Submission status: Runtime Error

Solution code:
import numpy as np


def bruteforce(c, k):
    c = c.tolist()
    n = 0
    while True:
        if len(c) < k:
            return n
        for i in range(k):
            c[i] -= 1
        c = [ci for ci in c if ci != 0]
        n += 1

def diff(x):
    ret = np.zeros_like(x)
    ret[1:] = np.diff(x)
    return ret

def test(c, k):
    if k == 1:
        return np.sum(c)
    if len(c) < k:
        return 0
    f = np.sort(c[:k])
    remain = sum(c[k:])
    d = diff(f)
    cost = np.arange(len(d)) * d
    for i, cos in enumerate(cost):
        if cos <= remain:
            remain -= cos
        else:
            if i == 0:
                return f[0]
            else:
                return f[i - 1]
    return c[0] + remain // k


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

    A = sorted(A)
    _, c = np.unique(A, return_counts=True)

    c = np.sort(c)[::-1]
    for k in range(1, N + 1):
        print(test(c, k))
    # for k in range(1, 7):
        # print(test(c, k), bruteforce(c, k))
        # print(bruteforce(c, k))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import numpy as np
#from collections import Counter
N = int(input())
#c = Counter(map(int, input().split()))
#C = list(c.values())
c = list(map(int, input().split()))
unique, C = np.unique(c, return_counts = True)
C.sort()
C= np.array(C)
lenc = len(C)
ans = np.array([0]*(N+1))
for num in range(1, N+1):
    sum1 = np.minimum(C, np.array([num]*lenc))
    ans[:((np.sum(np.array(sum1)) // num) + 1 )] = num

for i in ans[1:]:
    print(i)

Submission status: Runtime Error

Solution code:
from collections import Counter
N = int(input())
c = Counter(map(int, input().split()))
C = list(c.values())
C.sort()
C= np.array(C)
lenc = len(C)
ans = [0]*(N+1)
for num in range(1, N+1):
    sum1 = np.minimum(C, np.array([num]*lenc))
    ans[np.sum(np.array(sum1)) // num] = num

m = 0
for i,name in enumerate(ans[::-1]):
    m = max(m,name)
    ans[-(i+1)] = m

for i in ans[1:]:
    print(i)

Submission status: Runtime Error

Solution code:
from collections import Counter
N = int(input())
c = Counter(map(int, input().split()))
C = list(c.values())
C.sort()

ans = [0]*(N+1)
for num in range(1, N+1):

    sum1 = []
    for i in C:
        sum1.append(min(i, num))
    ans[np.sum(np.array(sum1)) // num] = num

m = 0
for i,name in enumerate(ans[::-1]):
    m = max(m,name)
    ans[-(i+1)] = m

for i in ans[1:]:
    print(i)

Submission status: Runtime Error

Solution code:
from collections import Counter

N = int(input())
 
lines = input().split(' ')
 
lis = Counter(lines).values()
# dic = {}
# for item in lines:
#     n = int(item)
 
#     if n in dic.keys():
#         dic[n] += 1
#     else:
#         dic[n] = 1
 
# lis = list(dic.values())
# for item in dic.keys():
#     lis += [dic[item]]
 
lis.sort(reverse=True)
 
sublis = []
sublis = lis[:]
 
def cal(k,lis):
    ans = 0
    if (len(lis)<k):
        return 0
    
    while True:
        for k_i in range(k):
            if lis[k_i] == 0:
                return ans
            else:
                lis[k_i] -= 1
        else:
            ans += 1
 
        lis.sort(reverse=True)
 
 
for i in range(N):
    lis = sublis[:]
    print(cal(i+1,lis))

Submission status: Runtime Error

Solution code:
import copy
import sys

input = sys.stdin.readline
N=int(input())
A = [int(input()) for _ in range(N)]
A.sort()
B=[]

for a in A:
    if(A.count(a)!=0):
        B.append([a,A.count(a)])
        A=[i for i in A if i!=a]

B=sorted(B,key=lambda x: x[1],reverse=True)

for n in range(1,N+1):
    if(n==1)
    #初期設定
    B_=copy.deepcopy(B)
    counter=0
    while n<=len(B_):
        counter+=B_[n-1][1]
        for k in range(0,n-1):
            B_[k][1]-=B_[n-1][1]
        B_.pop(n-1)
        B_=sorted(B_,key=lambda x: x[1],reverse=True)
    print(counter)

Submission status: Runtime Error

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

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

#output
from collections import Counter
import bisect
import numpy as np

l = Counter(A).most_common()
l = [b for a, b in l]
l = np.array(l)
M = len(l)
np.sort(l)
m = np.cumsum(l)
p = m[-1]

maximum_operation = [0] * N

ll = np.array([])
for x in range(1, N+1):
    a = bisect.bisect_left(l, x)
    if a == 0:
        b = M*x
        c = 0
    elif a >= M:
        b = 0
        c = p
    else:
        b = (M-a)*x
        c = m[a-1] 
    ll.append((b + c)/x)
np.sort(ll)

for K in range(M):
    maximum_operation[K] = N - bisect.bisect_left(ll, K+1)

for m in maximum_operation:
    print(m)

Submission status: Runtime Error

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

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

#output
from collections import Counter
import bisect
import numpy as np

l = Counter(A).most_common()
l = [b for a, b in l]
M = len(l)
l.sort()
m = np.cumsum(l)
p = m[-1]

maximum_operation = [0] * N

ll = []
for x in range(1, N+1):
    a = bi.bisect_left(l, x)
    if a == 0:
        b = M*x
        c = 0
    elif a >= M:
        b = 0
        c = p
    else:
        b = (M-a)*x
        c = m[a-1] 
    ll.append((b + c)/x)
ll.sort()

for K in range(M):
    maximum_operation[K] = N - bisect.bisect_left(ll, K+1)

for m in maximum_operation:
    print(m)

Submission status: Runtime Error

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

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

#output
from collections import Counter
import bisect

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

number_of_operation = [0] * O
maximum_operation = [0] * N

ll = []
for x in reversed(range(1, N+1)):
    ll.append(sum([min(x, i) for i in l]) / x)

for K in range(M):
    maximum_operation[K] = N-bisect.bisect_left(ll, K+1)

for m in maximum_operation:
    print(m)

Submission status: Runtime Error

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

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

#output
from collections import Counter
import bisect as bi

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

number_of_operation = [0] * O
maximum_operation = [0] * N

ll = []
for x in reversed(range(1, N+1)):
    ll.append(sum([min(x, i) for i in l]) / x)

for K in range(M):
    maximum_operation[K] = N-bi.bisect_left(ll, K+1)

for m in maximum_operation:
    print(m)

Submission status: Runtime Error

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

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

#output
from collections import Counter
import bisect as bi

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

number_of_operation = [0] * O
maximum_operation = [0] * N

ll = []
for x in reversed(range(1, N+1)):
    ll.append(sum([min(x, i) for i in l]) / x)

for K in range(M):
    maximum_operation[K] = N-bi.bisect_left(ll, K+1)

for m in maximum_operation:
    print(m)

Submission status: Runtime Error

Solution code:
from copy import deepcopy
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.deepcopy()
        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: Runtime Error

Solution code:
N = int(input())

line = input()
# N = 3
### line = '2 1 2'
lines = line.split(' ')


dic = {}
for item in lines:
    n = int(item)

    if n in dic.keys():
        dic[n] += 1
    else:
        dic[n] = 1

lis = dic.values()
# for item in dic.keys():
#     lis += [dic[item]]

lis.sort(reverse=True)

sublis = []
sublis = lis[:]

def cal(k,lis):
    ans = 0
    if (len(lis)<k):
        return 0
    
    while True:
        for k_i in range(k):
            if lis[k_i] == 0:
                return ans
            else:
                lis[k_i] -= 1
        else:
            ans += 1

        lis.sort(reverse=True)


for i in range(N):

    lis = sublis[:]
    print(cal(i+1,lis))

Submission status: Runtime Error

Solution code:
N = int(input())

line = input()
# N = 3
### line = '2 1 2'
lines = line.split(' ')


dic = {}
for item in lines:
    n = int(item)

    if n in dic.keys():
        dic[n] += 1
    else:
        dic[n] = 1

lis = map(dic.values())
# for item in dic.keys():
#     lis += [dic[item]]

lis.sort(reverse=True)

sublis = []
sublis = lis[:]

def cal(k,lis):
    ans = 0
    if (len(lis)<k):
        return 0
    
    while True:
        for k_i in range(k):
            if lis[k_i] == 0:
                return ans
            else:
                lis[k_i] -= 1
        else:
            ans += 1

        lis.sort(reverse=True)


for i in range(N):

    lis = sublis[:]
    print(cal(i+1,lis))

Submission status: Runtime Error

Solution code:
N = int(input())

line = input()
# N = 3
### line = '2 1 2'
lines = line.split(' ')


dic = {}
for item in lines:
    n = int(item)

    if n in dic.keys():
        dic[n] += 1
    else:
        dic[n] = 1

lis = dic.items()
# for item in dic.keys():
#     lis += [dic[item]]

lis.sort(reverse=True)

sublis = []
sublis = lis[:]

def cal(k,lis):
    ans = 0
    if (len(lis)<k):
        return 0
    
    while True:
        for k_i in range(k):
            if lis[k_i] == 0:
                return ans
            else:
                lis[k_i] -= 1
        else:
            ans += 1

        lis.sort(reverse=True)


for i in range(N):

    k = i + 1
    lis = sublis[:]
    print(cal(k,lis))

Submission status: Runtime Error

Solution code:
import numpy as np
np.unique(np.array([1,2,3]), return_counts=True)

Submission status: Runtime Error

Solution code:
import numpy as np

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

for k in range(1, n+1):
    _, counts = np.unique(a, return_counts=True)
    counts = sorted(list(counts), reverse=True)
    
    eat = 0
    while True:
        if np.count_nonzero(counts) < k:
            break
        else:
            for i in range(k):
                counts[i] -= 1
            eat += 1
            counts = sorted(list(counts), reverse=True)
            
    print(eat)

Submission status: Runtime Error

Solution code:
import numpy as np
import heapq
import copy
from operator import itemgetter


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

for k in range(1, n+1):
    _, counts = np.unique(a, return_counts=True)
    counts = sorted(list(counts), reverse=True)
    
    eat = 0
    while True:
        if np.count_nonzero(counts) < k:
            break
        else:
            for i in range(k):
                counts[i] -= 1
            eat += 1
            counts = sorted(list(counts), reverse=True)
            
    print(eat)