line1 = input() line2 = input() line1 = int(line1) line2 = list(map(int, line2.split(" "))) from collections import Counter counts = Counter(line2) counts = list(counts.values()) counts.sort() total_sum = sum(counts) ans = [total_sum] for k in range(2, line1+1): ss = 0 for c in reversed(counts): if c < k: break ss += c - c % k if counts[-1] >= k: ans.append(ss) else: break ans = ans + [0]*(line1 - len(ans)) ans = " ".join(list(map(str, ans))) print(ans)
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 26 27 | line1 = input() line2 = input() line1 = int(line1) line2 = list(map(int, line2.split(" "))) from collections import Counter counts = Counter(line2) counts = list(counts.values()) counts.sort() total_sum = sum(counts) ans = [total_sum] for k in range(2, line1+1): ss = 0 for c in reversed(counts): if c < k: break ss += c - c % k if counts[-1] >= k: ans.append(ss) else: break ans = ans + [0]*(line1 - len(ans)) ans = " ".join(list(map(str, ans))) print(ans) |