from collections import Counter n = int(input()) a = list(map(int, input().split())) cities_counts = Counter(a) d = {} def get_max(k): if k in d: return d[k] sum = 0 for count in cities_counts.values(): max_value = (count // k) * k sum += max_value d[k] = sum return sum result = [get_max(k) for k in range(1, n + 1)] print(' '.join(str(item) for item in result))
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | from collections import Counter n = int(input()) a = list(map(int, input().split())) cities_counts = Counter(a) d = {} def get_max(k): if k in d: return d[k] sum = 0 for count in cities_counts.values(): max_value = (count // k) * k sum += max_value d[k] = sum return sum result = [get_max(k) for k in range(1, n + 1)] print(' '.join(str(item) for item in result)) |