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:
n = int(input())
li = [int(x) for x in input().split()]
l2 = set(li)
for k in range(1,n+1):
    if k==1:
        print(n)
    else:
        print(len(l2)//k)

Submission status: Wrong Answer

Solution code:
from collections import Counter
import bisect


def main():
    N = int(input())
    A = list(map(int, input().split()))
    count_list = list(Counter(A).values())
    count_list.sort()
    cumsum_count = [0] * len(count_list)
    cumsum_count[0] = count_list[0]
    for i in range(1, len(count_list)):
        cumsum_count[i] = cumsum_count[i - 1] + count_list[i]
    ans_list = [0] * N
    for k in range(1, len(count_list) + 1):
        # 最大でも　n_max = N // k 回まで。
        # 各カード n_max 枚まで使って k * n_max の長方形領域を1列ずつ貪欲に埋めていくイメージ。
        # 最終列の不足分を均等に他の列に分散させ、列の高さの最小値が答え
        n_max = N // k
        s = 0
        # n_max 枚以上あるカードは n_max 枚固定
        index = bisect.bisect_left(count_list, n_max)
        count_max = len(count_list) - index
        s += n_max * count_max
        # それ未満のカードはそのまま全部使う
        if index > 0:
            s += cumsum_count[index - 1]
        # 長方形領域をはみ出た部分をカット
        s = min(s, k * n_max)
        # 不足分を均等に配分した時の列の高さの最小値が答え
        ns = k * n_max - s
        ans_list[k - 1] = n_max - ((ns + k - 1) // k)
    for ans in ans_list:
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter
import bisect


def main():
    N = int(input())
    A = list(map(int, input().split()))
    count_list = list(Counter(A).values())
    count_list.sort()
    cumsum_count = [0] * len(count_list)
    cumsum_count[0] = count_list[0]
    for i in range(1, len(count_list)):
        cumsum_count[i] = cumsum_count[i - 1] + count_list[i]
    ans_list = [0] * N
    for k in range(1, len(count_list) + 1):
        # 最大でも　n_max = N // k 回まで。
        # 各カード n_max 枚まで使って k * n_max の長方形領域を1列ずつ貪欲に埋めていくイメージ。
        # 最終列の高さが答え。
        n_max = N // k
        s = 0
        # n_max 枚以上あるカードは n_max 枚固定
        index = bisect.bisect_left(count_list, n_max)
        count_max = len(count_list) - index
        s += n_max * count_max
        # それ未満のカードはそのまま全部使う
        if index > 0:
            s += cumsum_count[index - 1]
        # 長方形領域をはみ出た部分をカット
        s = min(s, k * n_max)
        # 答えは最終列の高さ
        ans_list[k - 1] = n_max - (k * n_max - s)
    for ans in ans_list:
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
C = [0] * (N+1)
Cnt_A = [0] * (N+1)
for a in A:
    Cnt_A[a] += 1
    cnt = Cnt_A[a]
    C[cnt] += 1
C[0] = N
B = []
for c1, c2 in zip(C, C[1:]):
    B += [c1] * c2
Ans = []
a = 1
for ans, b in zip(range(N, 0, -1), B[::-1]):
    while a <= b:
        Ans.append(ans//a)
        a += 1
print("\n".join(map(str, Ans)))

Submission status: Wrong Answer

Solution code:
from collections import Counter
from itertools import accumulate
n = int(input())
A = tuple(map(int, input().split()))
C = Counter(A)
D = [0]*(n+1)
for v in C.values():
  D[v] += 1
E = tuple(accumulate(k*d for k, d in enumerate(D)))
D = tuple(accumulate(D))
F = [0]*(n+1)
for x in range(1, n+1):
  temp = (E[x] + x*(D[n]-D[x])) // x
  F[x] = temp
print(*F[1:], sep="\n")

Submission status: Wrong Answer

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

from collections import Counter
c = Counter(a)
a = list(c.values())
a.sort(reverse=True)
l = len(a)
cum = [None]*l
v = a[-1]
for i in range(l-1, -1, -1):
    cum[i] = v
    v += a[i-1]
cum.append(0)
ans = [None]*n
ans[0] = n
for k in range(2,n+1):
    if k>l:
        val = 0
    else:
        if a[k-2]>=cum[k-1]:
            val = cum[k-1]
#             print("c", val)
        else:
            def sub(x):
                # 0,...,x-1とx以降に分けたとき、後半が多い
                return a[x-1]*(k-x)<=cum[x]
            if sub(1):
                val = a[0] + (cum[1]-a[0]*(k-1))//k
#                 print("a", val)
            else:
                l = 1
                r = k-1
                assert sub(r)
                while l+1<r:
                    m = (l+r)//2
                    if sub(m):
                        l = m
                    else:
                        r = m
                val = cum[r]//(k-r)
#                 print("b", val)
    ans[k-1] = val
write("\n".join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

from collections import Counter
c = Counter(a)
a = list(c.values())
a.sort(reverse=True)
l = len(a)
cum = [None]*l
v = a[-1]
for i in range(l-1, -1, -1):
    cum[i] = v
    v += a[i-1]
cum.append(0)
ans = [None]*n
ans[0] = n
for k in range(2,n+1):
    if k>l:
        val = 0
    else:
        if a[k-2]>=cum[k-1]:
            val = cum[k-1]
#             print("c", val)
        else:
            def sub(x):
                # 0,...,xとx+1以降に分けたとき、後半が多い
                return a[x]*(k-x-1)<=cum[x+1]
            if sub(0):
                val = a[0] + (cum[1]-a[0]*(k-1))//k
#                 print("a", val)
            else:
                l = 0
                r = k-1
                while l+1<r:
                    m = (l+r)//2
                    if sub(m):
                        l = m
                    else:
                        r = m
                val = cum[r]//(k-r)
#                 print("b", val)
    ans[k-1] = val
write("\n".join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

from collections import Counter
c = Counter(a)
a = list(c.values())
a.sort(reverse=True)
l = len(a)
cum = [None]*l
v = a[-1]
for i in range(l-1, -1, -1):
    cum[i] = v
    v += a[i-1]
cum.append(0)
ans = [None]*n
ans[0] = n
for k in range(2,n+1):
    if k>l:
        val = 0
    else:
        if a[k-2]>=cum[k-1]:
            val = cum[k-1]
#             print("c", val)
        else:
            if a[0]*(k-1)<=cum[1]:
                val = a[0] + (cum[1]-a[0]*(k-1))//k
#                 print("a", val)
            else:
                l = 0
                r = k-1
                while l+1<r:
                    m = (l+r)//2
                    if (k-m)*a[m-1] > cum[m]:
                        l = m
                    else:
                        r = m
                val = cum[r]//(k-r)
#                 print("b", val)
    ans[k-1] = val
write("\n".join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

from collections import Counter
c = Counter(a)
a = list(c.values())
a.sort(reverse=True)
l = len(a)
cum = [None]*l
v = a[-1]
for i in range(l-1, -1, -1):
    cum[i] = v
    v += a[i-1]
cum.append(0)
ans = [None]*n
ans[0] = n
for k in range(2,n+1):
    if k>l:
        val = 0
    else:
        if a[k-2]>=cum[k-1]:
            val = cum[k-1]
#             print("c", val)
        else:
            if a[0]*(k-1)<=cum[1]:
                val = a[0] + (cum[1]-a[0]*(k-1))//k
#                 print("a", val)
            else:
                l = 0
                r = k-1
                while l+1<r:
                    m = (l+r)//2
                    if (k-m)*a[m-1] > cum[m]:
                        l = m
                    else:
                        r = m
                val = cum[m]//(k-m)
#                 print("b", val)
    ans[k-1] = val
write("\n".join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

from collections import Counter
c = Counter(a)
a = list(c.values())
a.sort(reverse=True)
l = len(a)
cum = [None]*l
v = a[-1]
for i in range(l-1, -1, -1):
    cum[i] = v
    v += a[i-1]
cum.append(0)
ans = [None]*n
ans[0] = n
for k in range(2,n+1):
    if k>l:
        val = 0
    else:
        if a[k-2]>=cum[k-1]:
            val = cum[k-1]
#             print("c", val)
        else:
            if a[0]*(k-1)<=cum[1]:
                val = a[0] + (cum[1]-a[0]*(k-1))//k
#                 print("a", val)
            else:
                l = 0
                r = k-1
                while l+1<r:
                    m = (l+r)//2
                    if (k-m)*a[m-1] > cum[m]:
                        l = m
                    else:
                        r = m
                val = min(cum[m]//(k-m), a[m-1])
#                 print("b", val)
    ans[k-1] = val
write("\n".join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

from collections import Counter
c = Counter(a)
a = list(c.values())
a.sort(reverse=True)
l = len(a)
cum = [None]*l
v = a[-1]
for i in range(l-1, -1, -1):
    cum[i] = v
    v += a[i-1]
cum.append(0)
ans = [None]*n
ans[0] = n
flg = [False]*l
for i in range(l-1):
    if a[i]>=cum[i+1]:
        flg[i] = True
flg[-1] = True
index = [None]*l
v = None

for i in range(l):
    if flg[i]:
        v = i
    index[i] = v
# ind = None
# for i in range(l-1,-1,-1):
#     if index[i] is not None:
#         ind = i
#     else:
#         index[i] = ind
for k in range(2,n+1):
    if k>l:
        val = 0
    else:
        ind = index[k-1]
        if ind is None:
            ind = k-1
        val = a[ind]
        if k>ind+1:
            val = min(val+((cum[ind+1]-val*(k-(ind+1)))//(k-(ind+1)+1)), cum[ind+1]//(k-(ind+1)))
#         s = cum[k-1]
#         val = 0
#         ind = 1
#         while k-(ind+1)>=0 and (s//ind)>(a[k-(ind+1)]-val):
#             aa = a[k-(ind+1)] - val
#             val += aa
#             s -= aa*ind
#             ind += 1
#         else:
#             val += s//ind
            
    ans[k-1] = val
write("\n".join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

from collections import Counter
c = Counter(a)
a = list(c.values())
a.sort(reverse=True)
l = len(a)
cum = [None]*l
v = a[-1]
for i in range(l-1, -1, -1):
    cum[i] = v
    v += a[i-1]
cum.append(0)
ans = [None]*n
ans[0] = n
flg = [False]*l
for i in range(l-1):
    if a[i]>=cum[i+1]:
        flg[i] = True
flg[-1] = True
index = [None]*l
v = 0
for i in range(l):
    if flg[i]:
        v = i
    index[i] = v
# ind = None
# for i in range(l-1,-1,-1):
#     if index[i] is not None:
#         ind = i
#     else:
#         index[i] = ind
for k in range(2,n+1):
    if k>l:
        val = 0
    else:
        ind = index[k-1]
        val = a[ind]
        if k>ind+1:
            val = min(val+((cum[ind+1]-val*(k-(ind+1)))//(k-(ind+1)+1)), cum[ind+1]//(k-(ind+1)))
#         s = cum[k-1]
#         val = 0
#         ind = 1
#         while k-(ind+1)>=0 and (s//ind)>(a[k-(ind+1)]-val):
#             aa = a[k-(ind+1)] - val
#             val += aa
#             s -= aa*ind
#             ind += 1
#         else:
#             val += s//ind
            
    ans[k-1] = val
write("\n".join(map(str, ans)))

Submission status: Wrong Answer

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:
    t = T[K-1]
    ans += t
    for n in range(K-1, -1, -1):
      if T[n] > t:
        T[n] -= t
      else:
        T.pop(n)
  print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
c = Counter()
for x in a: c[x] += 1
cv = Counter()
for v in c.values(): cv[v] += 1
print(cv)

def check(x, K):
  t = 0
  for k, v in cv.items(): t += min(k, x) * v
  return t >= K * x

res = [N] * (N + 1)
for K in range(1, N):
  ok = 0
  ng = res[K] + 1
  while ng - ok > 1:
    m = (ok + ng) // 2
    if check(m, K + 1): ok = m
    else: ng = m
  res[K + 1] = ok

for r in res[1: ]: print(r)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
table = Counter()
for x in a: table[x] += 1
c = Counter()
for v in table.values(): c[v] += 1

res = [0] * (N + 1)
ks = sorted(c.keys())
ks.reverse()
for K in range(1, N + 1):
  res[K] = 0
  cc = Counter()
  for k, v in c.items(): cc[k] = v
  while True:
    t = 0
    used = 0
    #print(cc, K)
    for k in range(ks[0], 0, -1):
      if (cc[k] - used) > 0 and (k > 1):
        cc[k] -= 1
        used = 1
        cc[k - 1] += 1
        t += 1
      elif (cc[k] - used):
        if (cc[k] - used) >= K - t:
          cc[k] -= K - t
          t = K
      else: used = 0
      if t >= K: break
    else: break
    res[K] += 1
  if res[K] == 0: break
for r in res[1: ]: print(r)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
c = Counter()
for x in a: c[x] += 1

res = [0] * (N + 1)
ks = sorted(c.keys())
ks.reverse()
for K in range(1, N + 1):
  res[K] = 0
  cc = Counter()
  for k, v in c.items(): cc[k] = v
  while True:
    t = 0
    for k in ks:
      if cc[k]:
        cc[k] -= 1
        t += 1
      if t >= K: break
    else: break
    res[K] += 1
  if res[K] == 0: break
for r in res[1: ]: print(r)

Submission status: Wrong Answer

Solution code:
t=0
N=int(input())
L=list(map(int,input().split()))
print(N)
R=set(L)
c=len(R)
K=[L.count(i) for i in R]
P=sorted(list(K),reverse=True)
for i in range(2,N+1):
  a=0
  for j in range(1,c//i+1):
    a+=P[(j*i)-1]
  t+=a
  print(a)

Submission status: Wrong Answer

Solution code:
N=int(input())
L=list(map(int,input().split()))
print(N)
L=set(L)
c=len(L)
for i in range(2,N+1):
  print(c//i)

Submission status: Wrong Answer

Solution code:
def main():
    from sys import stdin
    input = stdin.readline
    from collections import Counter as ct
    from bisect import bisect_left as bl

    n = int(input())
    max_a = sorted(ct(list(map(int, input().split()))).values())
    now_a = [i for i in max_a]
    m = len(max_a)
    cnt = m
    ans = 0
    ans_list = [0]*(n-m)

    for use in range(m, 1, -1):
        rest = ans
        nex = now_a[0]
        while rest:
            val = nex
            start = bl(now_a, val+1)
            nex += 1
            q = bl(max_a, now_a[start-1]+1)-1
            for i in range(start-1, max(-1, start-1-rest, q), -1):
                now_a[i] += 1
            rest -= start-1-max(-1, start-1-rest, q)
            if now_a[start-1] == 0:
                cnt += start-1-max(-1, start-1-rest, q)
            if start != m:
                nex = now_a[start]
        while cnt >= use:
            ans += 1
            rest = use
            nex = now_a[-1]
            end = m
            while rest:
                val = nex
                start = bl(now_a, val)
                if start != 0:
                    nex = now_a[start-1]
                end = min(end, bl(now_a, val+1), start+rest)
                for i in range(start, end):
                    now_a[i] -= 1
                if now_a[start] == 0:
                    cnt -= end-start
                rest -= end-start
                end = start
        ans_list.append(ans)
    print(n)
    for i in ans_list[::-1]:
        print(i)


main()

Submission status: Wrong Answer

Solution code:
def main():
    from collections import Counter as ct
    from bisect import bisect_left as bl

    n = int(input())
    max_a = sorted(ct(list(map(int, input().split()))).values())
    now_a = [i for i in max_a]
    m = len(max_a)
    cnt = m
    ans = 0
    ans_list = [0]*(n-m)

    for use in range(m, 1, -1):
        rest = ans
        nex = now_a[0]
        while rest:
            val = nex
            start = bl(now_a, val+1)
            nex += 1
            for i in range(start-1, max(-1, start-1-rest), -1):
                if now_a[i] == max_a[i]:
                    if start != m:
                        nex = now_a[start]
                    break
                elif now_a[i] == 0:
                    cnt += 1
                now_a[i] += 1
                rest -= 1
        while cnt >= use:
            ans += 1
            rest = use
            nex = now_a[-1]
            end = m
            while rest:
                val = nex
                start = bl(now_a, val)
                if start != 0:
                    nex = now_a[start-1]
                flag = 0
                if now_a[start] == 1:
                    flag = 1
                end = min(end, bl(now_a, val+1), start+rest)
                for i in range(start, end):
                    cnt -= flag
                    now_a[i] -= 1
                    rest -= 1
                end = start
        ans_list.append(ans)
    print(n)
    for i in ans_list[::-1]:
        print(i)

Submission status: Wrong Answer

Solution code:
def main():
    from collections import Counter as ct
    from bisect import bisect_left as bl

    n = int(input())
    max_a = sorted(ct(list(map(int, input().split()))).values())
    now_a = [i for i in max_a]
    m = len(max_a)
    cnt = m
    ans = 0
    ans_list = []

    for use in range(n, 0, -1):
        rest = ans
        nex = now_a[0]
        # restの分だけ戻す
        while rest:
            val = nex
            start = bl(now_a, val+1)
            if start != m:
                nex = now_a[start]
            for i in range(start-1, -1, -1):
                if now_a[i] == max_a[i]:
                    break
                elif now_a[i] == 0:
                    cnt += 1
                now_a[i] += 1
                rest -= 1
                if rest == 0:
                    break
        # 大きい方から使っていく
        while True:
            if cnt < use:
                ans_list.append(ans)
                break
            ans += 1
            rest = use
            nex = now_a[-1]
            while rest:
                val = nex
                start = bl(now_a, val)
                if start != 0:
                    nex = now_a[start-1]
                for i in range(start, m):
                    if now_a[i] > val:
                        break
                    elif now_a[i] == 1:
                        cnt -= 1
                    now_a[i] -= 1
                    rest -= 1
                    if rest == 0:
                        break
    for i in ans_list[::-1]:
        print(i)


main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
table = [0] * (N + 1)
for x in a: table[x] += 1
ttable = [0] * (N + 1)
for x in table: ttable[x] += 1
for i in range(N, 0, -1): ttable[i - 1] += ttable[i]

res = [0] * (N + 1)
for k in range(1, N + 1):
  x = 0
  for i in range(1, N + 1):
    if ttable[i] + x < k: break
    res[k] += (ttable[i] + x) // k
    x = (ttable[i] + x) % k
for r in res[1: ]: print(r)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
table = [0] * (N + 1)
for x in a: table[x] += 1
ttable = [0] * (N + 1)
for x in table: ttable[x] += 1
for i in range(N, 0, -1): ttable[i - 1] += ttable[i]

res = [0] * (N + 1)
for k in range(1, N + 1):
  x = 0
  for i in range(1, N + 1):
    if ttable[i] < k: break
    res[k] += (ttable[i] + x) // k
    x = ttable[i] % k
for r in res[1: ]: print(r)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
count = Counter(A)
MAX = max(count.values())

print(N)
for K in range(2, N+1):
    ans = min((N - MAX) // (K - 1), N // K)
    print(ans)

Submission status: Wrong Answer

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

n = int(input())
a = list(map(int, input().split()))
b = sorted(Counter(a).values())
exist = len(b)
b = [0]*(n-exist)+b
c = list(accumulate([0]+b))

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

for k in range(n//2+1,n+1):
    if exist>=k:
        print(1)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
import bisect,copy

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

data=[0 for i in range(0,N+1)]
for i in range(0,N):
    data[A[i]]+=1

X=[]
for i in range(0,N+1):
    if data[i]!=0:
        X.append(data[i])

X.sort()
n=len(X)
Y=copy.copy(X)
for i in range(1,n):
    Y[i]+=Y[i-1]
ans={i:0 for i in range(0,N+1)}
ans[0]=float('inf')
#num以下の整数の和+num*(num+1以上の個数)
for i in range(1,N+1):
    index=bisect.bisect_left(X,i+1)
    t=Y[index-1]+(n-index)*i
    ans[i]=t//i

pointer=N
i=1
while N+1>i:
    if ans[pointer]>=i:
        print(pointer)
        i+=1
    else:
        pointer-=1

Submission status: Wrong Answer

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

n = int(input())
A = list(map(int, input().split()))
AC = Counter(A)
LA = list(AC.values())
LA.sort()
nagasa = len(LA)
AA = list(accumulate([0] + LA))


def min_hantei(i):
    return nagasa - bisect_left(LA, n // i)


def goukei(i):
    min_num = min_hantei(i)
    remain = nagasa - min_num
    return AA[remain] + min_num * n // i


def hantei(i, x):
    return goukei(i) >= i * x


def calc(i):
    ok = 0
    ng = n + 1
    while ng - ok > 1:
        mid = (ok + ng) // 2
        if hantei(i, mid):
            ok = mid
        else:
            ng = mid
    return ok


for i in range(1, n + 1):
    print(calc(i))


# A = [1, 3, 5, 7, 9]
# print(bisect_left(A, 2))
# print(bisect_right(A, 2))

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import bisect
from collections import Counter

n = ni()
a = na()

c = sorted(Counter(a).values())
cc = [c[0]]
m = len(c)
for i in range(1,m):
    cc.append(cc[-1]+c[i])

def is_ok(k,arg):
    b = bisect.bisect_right(c,arg)
    p = cc[b-1] + (m-b)*arg
    return True if p >= arg*k else False

for k in range(1,n+1):
    #にぶたん
    ok,ng = -1,n//k+1
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(k,mid):
            ok = mid
        else:
            ng = mid
    
    print(ok)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import bisect
from collections import Counter

n = ni()
a = na()
aa = [a[0]]
for i in range(1,n):
    aa.append(aa[-1]+a[i])

c = sorted(Counter(a).values())
cc = [c[0]]
m = len(c)
for i in range(1,m):
    cc.append(cc[-1]+c[i])

for k in range(1,n+1):
    def is_ok(arg):
        b = bisect.bisect_right(c,arg)
        p = cc[b-1] + (m-b)*arg
        return True if p >= arg*k else False

    #にぶたん
    ok,ng = -1,n+1
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    
    print(ok)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import bisect
from collections import Counter

n = ni()
a = na()
aa = [a[0]]
for i in range(1,n):
    aa.append(aa[-1]+a[i])

c = sorted(Counter(a).values())
cc = [c[0]]
m = len(c)
for i in range(1,m):
    cc.append(cc[-1]+c[i])

for k in range(1,n+1):
    def is_ok(arg):
        b = bisect.bisect_right(c,arg)
        p = cc[b-1] + (m-b)*arg
        return True if p >= arg*k else False

    #にぶたん
    ok,ng = -1,n
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    
    print(ok)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import bisect
from collections import Counter

n = ni()
a = na()
aa = [a[0]]
for i in range(1,n):
    aa.append(aa[-1]+a[i])

for k in range(1,n+1):
    c = sorted(Counter(a).values())
    cc = [c[0]]
    m = len(c)
    for i in range(1,m):
        cc.append(cc[-1]+c[i])

    def is_ok(arg):
        b = bisect.bisect_right(c,arg)
        p = cc[b-1] + (m-b)*arg
        return True if p >= arg*k else False

    #にぶたん
    ok,ng = 0,n//k+1
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    
    print(ok)

Submission status: Wrong Answer

Solution code:
def main():
    n=int(input())
    # s=input()
    l= list(map(int, input().split()))
    s=len(set(l))
    print(n)
    for i in range(1,n):
        print(s//(i+1))
    return
main()

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

print(n)
M = max(c.values())
for i in range(2, n+1):
	if len(c) < i:
		print(0)
	elif M * i <= n:
		print(n // i)
	else:
		print((n - M) // (i - 1))

Submission status: Wrong Answer

Solution code:
from collections import Counter
import sys
def input():
	return sys.stdin.readline()[:-1]

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

print(n)
M = max(c.values())
for i in range(2, n+1):
	if len(c) < i:
		print(0)
	elif M * i <= n:
		print(n // i)
	else:
		print((n - M) // (i - 1))

Submission status: Wrong Answer

Solution code:
import copy

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

count = [0] * (N + 2)

tmp = 0
c = 0
for a in A:
    if a != tmp:
        count[c] += 1
        c = 1
        tmp = a
    else:
        c += 1

count[c] += 1
count[0] -= 1
lst = copy.deepcopy(count)


for i in range(1, N + 1):
    count[i + 1] *= (i + 1)
    count[i + 1] += count[i]
    lst[i + 1] += lst[i]

# print (count)
# print (lst)

def calc(k):
    tmp = N // k #最大の回数
    # #最大回数より多い枚数の
    # over = N - count[tmp] + lst[tmp]

    #使える枚数
    use = count[tmp] + (lst[-1] - lst[tmp])
    # ans = (N - over) // k
    ans = min(use // k, tmp)

    return ans


for t in range(1, N + 1):
    print (calc(t))

Submission status: Wrong Answer

Solution code:
import copy

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

count = [0] * (N + 2)

tmp = 0
c = 0
for a in A:
    if a != tmp:
        count[c] += 1
        c = 1
        tmp = a
    else:
        c += 1

count[c] += 1
count[0] -= 1
lst = copy.deepcopy(count)


for i in range(1, N + 1):
    count[i + 1] *= (i + 1)
    count[i + 1] += count[i]
    lst[i + 1] += lst[i]

print (count)
print (lst)

def calc(k):
    tmp = N // k #最大の回数
    # #最大回数より多い枚数の
    # over = N - count[tmp] + lst[tmp]

    #使える枚数
    use = count[tmp] + (lst[-1] - lst[tmp])
    # ans = (N - over) // k
    ans = min(use // k, tmp)

    return ans


for t in range(1, N + 1):
    print (calc(t))

Submission status: Wrong Answer

Solution code:
import copy

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

count = [0] * (N + 1)

tmp = 0
c = 0
for a in A:
    if a != tmp:
        count[c] += 1
        c = 1
        tmp = a
    else:
        c += 1

count[c] += 1
count[0] -= 1
lst = copy.deepcopy(count)


for i in range(1, N):
    count[i + 1] *= (i + 1)
    count[i + 1] += count[i]
    lst[i + 1] += lst[i]

# print (count)
# print (lst)

def calc(k):
    tmp = N // k #最大の回数
    # #最大回数より多い枚数の
    # over = N - count[tmp] + lst[tmp]

    #使える枚数
    use = count[tmp] + (lst[-1] - lst[tmp])
    # ans = (N - over) // k
    ans = use // k

    return ans


for t in range(1, N + 1):
    print (calc(t))

Submission status: Wrong Answer

Solution code:
import collections

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

c = collections.Counter(a)

d = list(c.values())
d.sort()
d.reverse()
l = len(d)

ans = [0 for i in range(n)]

for k in range(n,0,-1):
    if k>l:
        ans[k-1]=0
    else:
        p = d.pop()
        if d:
            d[-1]+=p
        ans[k-1]=min(n//k, p)

for i in range(n):
    print(ans[i])

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

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[:]
    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)