import sys from collections import Counter n = int(sys.stdin.readline()) a = list(map(int, sys.stdin.readline().split())) d = Counter() for v in a: d[v] += 1 l = sorted(d.values()) ll = len(l) # print(l) s = 0 r = [0]*(n+1) r[1] = n for i in range(2, n+1): while s < ll and l[s] < i: s += 1 if s == ll: break for j in range(s, ll): r[i] += i * (l[j] // i) print(' '.join(str(x) for x in r[1:]))
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | import sys from collections import Counter n = int(sys.stdin.readline()) a = list(map(int, sys.stdin.readline().split())) d = Counter() for v in a: d[v] += 1 l = sorted(d.values()) ll = len(l) # print(l) s = 0 r = [0]*(n+1) r[1] = n for i in range(2, n+1): while s < ll and l[s] < i: s += 1 if s == ll: break for j in range(s, ll): r[i] += i * (l[j] // i) print(' '.join(str(x) for x in r[1:])) |