import sys def count(z, k): s = 0 i = 0 while i < len(z) and z[i] >= k: s += z[i] - z[i] % k i += 1 return s n = int(sys.stdin.readline().rstrip()) a = [int(i) for i in sys.stdin.readline().split()] c = dict() for i in a: c[i] = c.get(i, 0) + 1 b = sorted(list(c.values()), reverse=True) print(" ".join([str(count(b, k)) for k in range(1, n + 1)]))
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | import sys def count(z, k): s = 0 i = 0 while i < len(z) and z[i] >= k: s += z[i] - z[i] % k i += 1 return s n = int(sys.stdin.readline().rstrip()) a = [int(i) for i in sys.stdin.readline().split()] c = dict() for i in a: c[i] = c.get(i, 0) + 1 b = sorted(list(c.values()), reverse=True) print(" ".join([str(count(b, k)) for k in range(1, n + 1)])) |