DEBUG = True DEBUG = False n = int(input()) a = [int(i) for i in input().split(' ') if i != ''] b = {} for i in a: b[i] = b.get(i, 0) + 1 c = list(b.values()) c.sort(reverse=True) DEBUG and print("c: ", c) for i in range(1, n + 1): if i == 1: print(n, end=' ') else: s = 0 for j in c: s += j // i DEBUG and print("i: ", i, "j: ", j, j//i, "s: ", s) if j < i: break print(s * i, end=' ')
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 | DEBUG = True DEBUG = False n = int(input()) a = [int(i) for i in input().split(' ') if i != ''] b = {} for i in a: b[i] = b.get(i, 0) + 1 c = list(b.values()) c.sort(reverse=True) DEBUG and print("c: ", c) for i in range(1, n + 1): if i == 1: print(n, end=' ') else: s = 0 for j in c: s += j // i DEBUG and print("i: ", i, "j: ", j, j//i, "s: ", s) if j < i: break print(s * i, end=' ') |