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: Wrong Answer

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()))

import copy
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 = copy.deepcopy(H)
    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: Wrong Answer

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

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

for k in range(1,n+1):
    if len(population.keys()) < k:
        print(0)
    else:
        print(int(min(sum([v for v in population.values() if v <= n / k]),  n / k)))

Submission status: Wrong Answer

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

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

for k in range(1,n+1):
    if len(population.keys()) < k:
        print(0)
    else:
        print(int(min(sum([v for v in population.values() if v < n / k]),  n / k)))

Submission status: Wrong Answer

Solution code:
from collections import Counter as C
N = int(input())
A = sorted(list(C([int(a) for a in input().split()]).values()))
X = [0] * 303030
for a in A:
    X[a] += 1

s = 0
B = [0] * 303030
for i in range(300030)[::-1]:
    B[i] += s
    s += X[i]

def chk(k, a):
    if N - B[a] >= k * a: return 1
    return 0

for i in range(1, N+1):
    l, r = 0, N + 1
    while r-l > 1:
        m = (l+r) // 2
        if chk(i, m):
            l = m
        else:
            r = m
    print(l)

Submission status: Wrong Answer

Solution code:
from collections import Counter as C
X = [0] * 303030
N = int(input())
A = list(C([int(a) for a in input().split()]).values())
Y = [0] * 303030
for a in A: X[a] += 1
A = sorted(A)[::-1] + [0] * N
s = 0
c = 0
for i in range(300030)[::-1]:
    s += c
    c += X[i]
    Y[i] += s

def chk(i, a):
    if (N - Y[a+1]) >= (i+1) * a and a <= A[i]: return 1
    return 0

for i in range(N)[::-1]: A[i] += A[i+1]
for i in range(N):
    l, r = 0, N+1
    while r - l > 1:
        m = (l+r) // 2
        if chk(i, m):
            l = m
        else:
            r = m
    print(l)

Submission status: Wrong Answer

Solution code:
from collections import Counter as C
N = int(input())
X = [0] * 303030
A = list(C([int(a) for a in input().split()]).values())
for a in A: X[a] += 1
A = sorted(A)[::-1] + [0] * N
s = 0
for i in range(300030)[::-1]:
    if X[i]:
        X[i] = X[i+1] + s
        s += 1
    else:
        X[i] = X[i+1]

def chk(i, a):
    if (N - X[a+1]) >= (i+1) * a and a <= A[i]: return 1
    return 0

for i in range(N)[::-1]: A[i] += A[i+1]
for i in range(N):
    l, r = 0, N+1
    while r - l > 1:
        m = (l+r) // 2
        if chk(i, m):
            l = m
        else:
            r = m
    print(l)

Submission status: Wrong Answer

Solution code:
from collections import Counter as C
N = int(input())
X = [0] * 303030
A = list(C([int(a) for a in input().split()]).values())
for a in A: X[a] += 1
A = sorted(A)[::-1] + [0] * N
s = 0
for i in range(303030)[::-1]:
    X[i] += s
    s += X[i]

def chk(i, a):
    if (N - X[a+1]) >= (i+1) * a and a <= A[i]: return 1
    return 0

for i in range(N)[::-1]: A[i] += A[i+1]
for i in range(N):
    l, r = 0, N+1
    while r - l > 1:
        m = (l+r) // 2
        if chk(i, m):
            l = m
        else:
            r = m
    print(l)

Submission status: Wrong Answer

Solution code:
from collections import Counter as C
N = int(input())
A = sorted(list(C([int(a) for a in input().split()]).values()))[::-1] + [0] * N
for i in range(N)[::-1]: A[i] += A[i+1]
for i in range(N): print(min(N//(i+1), A[i]))

Submission status: Wrong Answer

Solution code:
I = int(input())
from collections import Counter
from itertools import accumulate
As = map(int, input().split())
xs = sorted([x for x in Counter(As).values()]) + [10**18]
Xs = accumulate(xs)
def F(x):
    return x < X//(l-k)


def bsearch(target, min_i, max_i, func):
    # func(index) <= target < func(index+1) となるindexを返す
    if func(max_i) <= target:
        return max_i
    if target < func(min_i):
        return min_i - 1
    index = (max_i + min_i)//2
    while True:
        if func(index) <= target:
            if target < func(index+1):
                return index
            index, min_i = (index+1 + max_i)//2, index+1
            continue
        index, max_i = (index-1 + min_i)//2, index-1

#for x in xs:
N = len(xs) - 1
rs = [0]*I
mny = I+1
for l, (x, X) in enumerate(zip(xs[1:], Xs)):
    l += 2
    y = bsearch(0, N-l+2, N, lambda k: x > X//(k-(N-l+1)))
    y+=1
    #print(l, y, X//(y-(N-l+1)))
    for i in range(y, mny):
        rs[i-1] = X//(i-(N-l+1))
    mny = min(y, mny)
for r in rs:
    print(r)

Submission status: Wrong Answer

Solution code:
import bisect
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] + 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: Wrong Answer

Solution code:
from collections import Counter
from itertools import accumulate

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

cnt = Counter(As)

Bs = [0] * (N+2)
for A, num in cnt.items():
    Bs[num] += 1

numGEs = list(accumulate(accumulate(Bs[::-1])))[::-1]

anss = []
for K in range(1, N+1):
    M = N//K
    numAvail = N - numGEs[M+1]
    ans = numAvail//K
    anss.append(ans)

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

Submission status: Wrong Answer

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[sum(sum1) // num] = num

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
types = {}
for i in A: types[i] = types.get(i, 0) + 1
A = sorted([types[k] for k in types], reverse=True)
L = len(A)
cumsum = [0 for i in range(L+1)]
for i in range(L-1, -1, -1):
    cumsum[i] = A[i] + cumsum[i+1]

# Highest K for given O
def calc(O):
    def getMidPoint(lo, hi):
        if lo >= hi: return lo
        mid = lo + (hi - lo+1) // 2
        if A[mid] > O:
            return getMidPoint(mid, hi)
        else:
            return getMidPoint(lo, mid-1)

    mid = getMidPoint(0, L-1)
    return (mid+1) + cumsum[mid+1] // O

for K in range(1, N+1):
    def getO(lo, hi):
        if lo >= hi: return lo
        mid = lo + (hi - lo+1) // 2
        if calc(mid) < K:
            return getO(lo, mid - 1)
        else:
            return getO(mid, hi)
        
    print(getO(0, N))

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
 
lines = input().split(' ')
 
lis = list(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):
    if i == 0:
        print(N)
        continue
    elif i == N-1:
        if len(lis) < N:
            print(0)
        else:
            print(min(lis))
        continue
    # lis = sublis[:]
    print(cal(i+1,lis))

Submission status: Wrong Answer

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)
l.sort()
p = sum(l)

maximum_operation = [0] * N

ll = []
for x in reversed(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 = sum(l[0:a-1]) 
    ll.append((b + c)/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: Wrong Answer

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)
np.sort(l)
m = np.cumsum(l)
p = m[-1]

maximum_operation = [0] * N

ll = []
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: Wrong Answer

Solution code:
import bisect
n = int(input())
a = [int(item) for item in input().split()]
cnt = [0] * (n + 1)
for item in a:
    cnt[item] += 1
cnt.sort()
cumsum = [0] * (n + 2)
for i in range(n+1):
    cumsum[i+1] = cumsum[i] + cnt[i]

ans = []
for i in range(n):
    if cnt[i+1] == 0:
        ans.append(0)
        continue
    radial = cumsum[i+1]
    l = 0; r = n+1
    while r - l > 1:
        mid = (l + r) // 2
        index = bisect.bisect_left(cnt, mid) - 1
        if index <= i:
            l = mid
            continue
        num = index - i
        csum = cumsum[index+1] - cumsum[i]
        if mid * num - csum < radial:
            l = mid
        else:
            r = mid
    ans.append(l)

ans.reverse()
for item in ans:
    print(item)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
c = Counter(map(int, input().split()))
cnt = sorted(c.values())
hist = [0]*(cnt[-1]+10)
for i in cnt:
    hist[0] += 1
    hist[i] -= 1

for i in range(1, len(hist)):
    hist[i] += hist[i-1]

ans = [0]*n
i = 0
cnt = 1
while hist[i]:
    while hist[i] == hist[i+1]:
        i += 1
        cnt += 1
    for j in range(1000000):
        if j+1 > hist[i]:
            break
        if j+1 > n:
            break
        ans[j] += cnt*hist[i]//(j+1)
    i += 1
    cnt = 1

print(*ans, sep="\n")

Submission status: Wrong Answer

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

rest = N

for K in range(1, N + 1):
    d = K
    while C and C[- 1] > rest//d:
        rest -= C[- 1]
        C.pop()
        d -= 1
    print(rest//d)

Submission status: Wrong Answer

Solution code:
import collections
import numpy as np

# リストarrからx個の同じ長さの列を取り出す時の最大の長さ
# 発想: x個取り出す時、ある文字をx個より多く取り出して列に含むことはない
#       一方ある文字をその文字がある数よりも取り出して使うこともできない
#       つまり、min(arr.count(a), x)で、x個の同じ長さの列に使えるaの数がわかる
#       さらに、sum(min(arr.count(a),x))で、x個の同じ長さの列に使える文字の数がわかる
#       よって、sum(min(arr.count(a),x))//xで、x個の同じ長さの列の長さがわかる
#       発展的に、longest(arr,x)までの計算状況からlongest(arr,x+1)が計算できる
# def longest(arr, x):    # legacy
#     return sum(min(arr.count(a), x) for a in arr) // x


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

counter = collections.Counter(a)        #O(n)
nums = list(counter.values())           #O(n)
num_counter = collections.Counter(nums) #O(n)
lastest_add = np.count_nonzero(nums)    #O(n)
building, longests = [0], [0]
for i in range(1, n+1):                 #O(n)
    appended = building[-1] + lastest_add   #O(1)
    building.append(appended)               #O(1)
    longests.append(appended // i)          #O(1)
    lastest_add -= num_counter[i]           #O(1)


SAME_TO_THE_RIGHT = 'same to the right'
k_most = [0] * (n+1)
lastest_index = n
k_most[1] = n
for i in range(n, 0, -1):
    if longests[i] > longests[lastest_index]:
        k_most[n+1-lastest_index+1] = i
        lastest_index = i
    else :
        k_most[i] = SAME_TO_THE_RIGHT
    
for i in range(n, 0, -1):
    if k_most[i] == SAME_TO_THE_RIGHT:
        if i == n:
            k_most[i] = 0
        else:
            k_most[i] = k_most[i+1]

for k in range(1, n+1):
    print(k_most[k])

# print('----------------')
# for k in range(1, n+1):
#     maxindexes = list(i for i, x in enumerate(longests) if x >= k)
#     if maxindexes:
#         print(maxindexes[-1])
#     else:
#         print(0)

Submission status: Wrong Answer

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)
O = l[0]
l.sort()

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

for o in range(O):
    number_of_operation[o] = M - bi.bisect_right(l, o)

for K in range(N):
    temp_number_of_operation = list(number_of_operation)
    for o in range(O-1):
        p, q = divmod(temp_number_of_operation[o], K+1)
        if p > 0:
            temp_number_of_operation[o+1] += q
        maximum_operation[K] += p
    maximum_operation[K] += temp_number_of_operation[-1]//(K+1)

for m in maximum_operation:
    print(m)

Submission status: Wrong Answer

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 = []
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 = ans + 1

        lis.sort(reverse=True)

    

for i in range(N):

    k = i + 1

    print(cal(k,lis))

Submission status: Wrong Answer

Solution code:
import numpy as np
import collections

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

for k in range(1, n+1):
    counts = collections.Counter(a).values()
    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[:k]), reverse=True)
            
    print(eat)

Submission status: Wrong Answer

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]
M = len(l)
O = l[0]

number_of_operation = [0] * O
maximum_operation = [0] * N
operation_matrix = np.zeros((O, M), int)

for m in range(M):
    operation_matrix[0:l[m], m] += 1

for o in range(O):
    number_of_operation[o] = sum(operation_matrix[o])

for K in range(N):
    temp_number_of_operation = list(number_of_operation)
    for o in range(O-1):
        p, q = divmod(temp_number_of_operation[o], K+1)
        if p > 0:
            temp_number_of_operation[o+1] += q
        maximum_operation[K] += p
    maximum_operation[K] += temp_number_of_operation[-1]//(K+1)

for m in maximum_operation:
    print(m)

Submission status: Wrong Answer

Solution code:
import numpy as np
np.count_nonzero

Submission status: Wrong Answer

Solution code:
import numpy as np
np.unique

Submission status: Wrong Answer

Solution code:
import bisect

n = int(input())
a = sorted([int(x) for x in input().split()])
num = len(set(a))

aa = []
cnt = 1
for i in range(1, n):
    if a[i] == a[i-1]:
        cnt += 1
    else:
        aa.append(cnt)
        cnt = 1
aa.append(cnt)
aa.sort()

# k=1 : ans = n
print(n)

# 2 <= k <= num : ans = {sum(min(cnt, n//k))} // k
i = 0
s = sum(aa)
for k in range(2, n+1):
    while(aa[-i-1] >= n//k and i<len(aa)-1):
        s -= aa[-i-1]
        i += 1
    print((i*(n//k) + s) // k) #aa[:i]

Submission status: Wrong Answer

Solution code:
import bisect
import copy

n = int(input())
a = sorted([int(x) for x in input().split()])
num = len(set(a))

aa = []
cnt = 1
for i in range(1, n):
    if a[i] == a[i-1]:
        cnt += 1
    else:
        aa.append(cnt)
        cnt = 1
aa.append(cnt)
aa.sort()

# k=1 : ans = n
print(n)

# 2 <= k <= num : ans = {sum(min(cnt, n//k))} // k
i = 0
s = sum(aa)
for k in range(2, num+1):
    while(aa[-i-1] >= n//k and i<len(aa)-1):
        s -= aa[-i-1]
        i += 1
    print((i*(n//k) + s) // k) #aa[:i]

# num < k : ans = 0
for k in range(num+1, n+1):
    print(0)

Submission status: Wrong Answer

Solution code:
import copy
import bisect

N = int(input())
A = map(int, input().split())
C = [0]*(N + 1)
for a in A:
    C[a] += 1
sorted_C = sorted(C)

def h(L, i):
    """
    sorted_C[N - i : N]の最小の所に、sorted_C[ : N - i]を順番に積み上げるイメージ
    """
    if i == 1:
        return N
    
    if i > N//2:
        if L[N - i] == 0:
            return 0
        else:
            return 1
    
    for j in range(N - i, 0, - 1):
        if L[j] == 0:
            return L[N - i + 1]
        
        L[N - i + 1] += L[j]
        a = bisect.bisect_right(L[N - i + 2: ], L[N - i + 1])
        L[N - i + 1:] = L[N - i + 2: N - i + 2 + a] + [L[N - i + 1]] + L[N - i + 2 + a :]
        # L[i -1]が大きくなったからソートし直す
        # これはL[0 : i - 2]はソート済みだからbisectでL[0 : i - 2]にL[i - 1]が入るいちを見つければ良い。下の解答参照
    return L[N - i + 1]
        
for i in range(N):
    L = copy.copy(sorted_C)
    print(h(L, i + 1))

Submission status: Wrong Answer

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

#output
from collections import Counter
import numpy as np

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

number_of_operation = [0] * O
maximum_operation = [0] * N
operation_matrix = np.zeros((O, M), int)

for m in range(M):
    operation_matrix[0:l[m], m] += 1

for o in range(O):
    number_of_operation[o] = sum(operation_matrix[o])

for K in range(N):
    temp_number_of_operation = list(number_of_operation)
    for o in range(O-1):
        p, q = divmod(temp_number_of_operation[o], K+1)
        if p > 0:
            temp_number_of_operation[o+1] += q
        maximum_operation[K] += p
    maximum_operation[K] += number_of_operation[O-1]//(K+1)

for m in maximum_operation:
    print(m)

Submission status: Wrong Answer

Solution code:
import bisect

n = int(input())
a = sorted([int(x) for x in input().split()])
num = len(set(a))

aa = []
cnt = 1
for i in range(1, n):
    if a[i] == a[i-1]:
        cnt += 1
    else:
        aa.append(cnt)
        cnt = 1
aa.append(cnt)
aa.sort()

# k=1 : ans = n
print(n)

# 2 <= k <= num : ans = {sum(min(cnt, n//k))} // k
i = len(aa)
for k in range(2, num+1):
    i = bisect.bisect(aa[:i], n//k)
    print(((len(aa)-i)*(n//k)+sum(aa[:i])) // k)

# num < k : ans = 0
for k in range(num+1, n+1):
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted([int(x) for x in input().split()])
num = len(set(a))

aa = []
i=0
while(i<n):
    cnt = a.count(a[i])
    #aa.append([a[i], cnt])
    aa.append(cnt)
    i += cnt
aa.sort(reverse=True)

# k=1
print(n)

# 2 <= k <= num
n_over = 0
i = 0
for k in range(2, num+1):
    if aa[i] > n//k:
        n_over += 1
        i += 1
    print((n_over*n//k + sum(aa[n_over:]))//k)
    #aaa = [min(cnt, n//k) for cnt in aa]
    #print(sum(aaa)//k)

# num < k
for k in range(num+1, n+1):
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted([int(x) for x in input().split()])
num = len(set(a))

aa = []
i=0
while(i<n):
    cnt = a.count(a[i])
    #aa.append([a[i], cnt])
    aa.append(cnt)
    i += cnt
aa.sort(reverse=True)

# k=1
print(n)

# 2 <= k <= num
n_over = 0
i = 0
for k in range(2, num+1):
    if aa[i] > n//k:
        n_over += 1
        i += 1
    print((k*n_over + sum(aa[n_over:]))//k)
    #aaa = [min(cnt, n//k) for cnt in aa]
    #print(sum(aaa)//k)

# num < k
for k in range(num+1, n+1):
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted([int(x) for x in input().split()])
num = len(set(a))

aa = []
i=0
while(i<n):
    cnt = a.count(a[i])
    #aa.append([a[i], cnt])
    aa.append(cnt)
    i += cnt
aa.sort(reverse=True)

# k=1
print(n)

# 2 <= k <= num
for k in range(2, num+1):
    aaa = [min(cnt, k) for cnt in aa]
    print(sum(aaa)//k)

# num < k
for k in range(num+1, n+1):
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted([int(x) for x in input().split()])
num = len(set(a))

aa = []
i=0
while(i<n):
    cnt = a.count(a[i])
    aa.append([a[i], cnt])
    i += cnt
aa.sort(reverse=True)

# k=1
print(n)

# 2 <= k <= num
for k in range(2, num+1):
    dup = 0
    for a_num, cnt in aa:
        if cnt > (n//k):
            dup += cnt - (n//k)
        else:
            break
    #print('cnt=', cnt)
    print((n-dup)//k)

for k in range(num+1, n+1):
    print(0)

Submission status: Wrong Answer

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

import copy
for k in range(1,N+1):
  l = copy.copy(A)
  cnt = 0
  while True:
    draw = []
    for i in range(len(l)):
      if l[i] not in draw and l[i] != 0:
        draw.append(l[i])
        l[i] = 0
      if len(draw) == k:
        cnt += 1
        draw = []
    if len(draw) != k:
      break
  print(cnt)

Submission status: Wrong Answer

Solution code:
import copy
N = 4
A = "1 3 3 3"
A = A.split(" ")
b = set(A)
print(N)
num_value = []
for i in b:
    num_value.append(A.count(i))
num_value.sort(reverse = True)
result = [0 for i in range(N + 1)]
i = 2
memory = copy.deepcopy(num_value)
while i != N + 1 :
    new_num = []
    if len(num_value) >= i :
        for j in range(i):
            num_value[j] -= 1
        for k in num_value:
            if k > 0:
                new_num.append(k)
        num_value = copy.deepcopy(new_num)
        result[i] += 1
    else :
        print(result[i])
        i += 1
        num_value = copy.deepcopy(memory)

Submission status: Wrong Answer

Solution code:
import copy
N = int(input(""))
A = input("")
#N = 5
#A = "1 2 3 4 5"
A = A.split(" ")
num = {}
print(N)
for i in A:
    if not i in num.keys():
        num[i] = A.count(i)
num_value = list(num.values())
num_value.sort(reverse = True)
result = [0 for i in range(N + 1)]
i = 2
memory = copy.deepcopy(num_value)
while i != N + 1 :
    new_num = []
    if len(num_value) >= i :
        print(num_value)
        for j in range(i):
            num_value[j] -= 1
        for k in num_value:
            if k != 0:
                new_num.append(k)
        num_value = copy.deepcopy(new_num)
        result[i] += 1
    else :
        print(num_value)
        print(result[i])
        i += 1
        num_value = copy.deepcopy(memory)
        print("---")

Submission status: Wrong Answer

Solution code:
import copy
N = int(input(""))
A = input("")
A = A.split(" ")
num = {}
num_key = 0
print(N)
for i in A:
    if not i in num.keys():
        num[i] = A.count(i)
num_key = len(num.keys())
num_value = list(num.values())
num_value.sort(reverse = True)
result = [0 for i in range(N + 1)]
i = 2
memory = num_value
while i != N + 1 :
    new_num = []
    if len(num_value) >= i :
        for j in range(i):
            num_value[j] -= 1
        for k in num_value:
            if k != 0:
                new_num.append(k)
        num_value = copy.deepcopy(new_num)
        result[i] += 1
    else :
        print(result[i])
        i += 1
        num_value = copy.deepcopy(memory)

Submission status: Wrong Answer

Solution code:
import copy
N = int(input(""))
A = input("")
A = A.split(" ")
num = {}
num_key = 0
print(N)
for i in A:
    if not i in num.keys():
        num[i] = A.count(i)
num_key = len(num.keys())
num_value = list(num.values())
num_value.sort(reverse = True)
result = []
for i in range(N+1):
  result.append(0)
i = 2
memory = num_value
while i != N + 1 :
    new_num = []
    if len(num_value) >= i :
        for j in range(i):
            num_value[j] -= 1
        for k in num_value:
            if k != 0:
                new_num.append(k)
        num_value = copy.deepcopy(new_num)
        result[i] += 1
    else :
        print(result[i])
        i += 1
        num_value = copy.deepcopy(memory)

Submission status: Wrong Answer

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

import copy
for k in range(1,N+1):
  cnt = 0
  A_copy = copy.copy(A)
  while len(set([A_copy[i] for i in range(len(A_copy)) if A_copy[i] != 0])) >= k:
    draw = []
    for i in range(len(A_copy)):
      if A_copy[i] not in draw and A_copy[i] != 0:
        draw.append(A_copy[i])
        A_copy[i] = 0
      if len(draw) == k:
        break
    cnt += 1
  print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input(""))
A = input("")
A = A.split(" ")
num = {}
num_key = 0
print(N)
for i in A:
    if not i in num.keys():
        num[i] = A.count(i)
num_key = len(num.keys())
num_value = list(num.values())
num_value.sort(reverse = True)
result = []
for i in range(N+1):
  result.append(0)
i = 2
memory = num_value
while i != N + 1 :
    new_num = []
    if len(num_value) >= i :
        for j in range(i):
            num_value[j] -= 1
        for k in num_value:
            if k != 0:
                new_num.append(k)
        num_value = new_num
        result[i] += 1
    else :
        print(result[i])
        i += 1
        num_value = memory

Submission status: Wrong Answer

Solution code:
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

LenN = [reduce(lambda y,z: y+X if z > X else y+z, BN)/X for X in xrange(1, N+1)]

KN = [0 for i in xrange(N)]
for i in xrange(len(LenN)):
    KN[LenN[i]-1] = i+1

for i in xrange(len(KN)-2, -1, -1):
    if KN[i] == 0:
        KN[i] = KN[i+1]

for i in KN:
    print (str(i))

Submission status: Wrong Answer

Solution code:
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

r = [reduce(lambda y,z: y+X if z > X else y+z, BN)/X for X in xrange(1, N+1)]

import sys
sys.stderr.write(str(r) + '\n')
for K in xrange(1, N+1):
    for i in xrange(len(r)-1, -1, -1):
        if r[i] >= K:
            print (str(i+1))
            break
    else:
        print (str(0))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from bisect import bisect
N = int(input())
A = list(map(int,input().split()))

d = defaultdict(lambda:0)

for i in range(N):
    d[A[i]] += 1

C = [0]*(N+1)

for i in d:
    C[d[i]] += 1

C1 = [0]*(N+1)
C2 = [0]*(N+1)

for i in range(N):
    C1[i+1] = C1[i] + (i+1)*C[i+1]
    C2[i+1] = C2[i] + C[i+1]

l = [0]*N
for n in range(N):
    l[n] = (C1[n+1]+C2[N]-C2[n+1])//(n+1)
    l[n] *= -1

for n in range(N-2,-1,-1):
    if l[n] > l[n+1]:
        l[n] = l[n+1]

for i in range(N):
    print(bisect(l,-(i+1)))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from bisect import bisect
N = int(input())
A = list(map(int,input().split()))

d = defaultdict(lambda:0)

for i in range(N):
    d[A[i]] += 1

C = [0]*(N+1)

for i in d:
    C[d[i]] += 1

C1 = [0]*(N+1)
C2 = [0]*(N+1)

for i in range(N):
    C1[i+1] = C1[i] + (i+1)*C[i+1]
    C2[i+1] = C2[i] + C[i+1]

l = [0]*N
for n in range(N):
    l[n] = (C1[n+1]+C2[N]-C2[n+1])//(n+1)
    l[n] *= -1

for i in range(N):
    print(bisect(l,-(i+1)))

Submission status: Wrong Answer

Solution code:
import sys 
import collections as cl
N=int(input())
A=list(map(int,sys.stdin.readline().split()))
c=cl.Counter(A)
NumberList=[x for x in c.values()]
LengthOfNumberList=len(NumberList)
FormulaList=[sum([min(NumberList[i],x)/x for i in range(LengthOfNumberList)]) for x in range(1,N+1)]
FormulaList.sort(reverse=True)
pin=N-1
for K in range(1,N+1):
    while pin>=0 and K>FormulaList[pin]:
        pin-=1
    print(pin+1)

Submission status: Wrong Answer

Solution code:
import sys 
import collections as cl
N=int(input())
A=list(map(int,sys.stdin.readline().split()))
c=cl.Counter(A)
NumberTupleList=c.most_common()
NumberList=[x[1] for x in NumberTupleList[::-1]]
LengthOfNumberList=len(NumberList)
FormulaList=[sum([min(NumberList[i],x)/x for i in range(LengthOfNumberList)]) for x in range(1,N+1)]

pin=N-1
for K in range(1,N+1):
    while pin>=0 and K>FormulaList[pin]:
        pin-=1
    print(pin+1)

Submission status: Wrong Answer

Solution code:
import sys 
import collections as cl
N=int(input())
A=list(map(int,sys.stdin.readline().split()))
c=cl.Counter(A)
NumberTupleList=c.most_common()
NumberList=[x[1] for x in NumberTupleList[::-1]]
LengthOfNumberList=len(NumberList)
FormulaList=[sum([min(NumberList[i],x)//x for i in range(LengthOfNumberList)]) for x in range(1,N+1)]

pin=N-1
for K in range(1,N+1):
    while pin>=0 and K>FormulaList[pin]:
        pin-=1
    print(pin+1)

Submission status: Wrong Answer

Solution code:
import sys 
import collections as cl
N=int(input())
A=list(map(int,sys.stdin.readline().split()))
c=cl.Counter(A)
NumberTupleList=c.most_common()
NumberList=[x[1] for x in NumberTupleList[::-1]]
LengthOfNumberList=len(NumberList)
FormulaList=[sum([min(NumberList[i],x)//x for i in range(LengthOfNumberList)]) for x in range(1,N+1)]

pin=N
for K in range(1,N+1):
    while pin>0 and K>FormulaList[pin-1]:
        pin-=1
    print(pin)