import sys
from collections import defaultdict
from typing import List
def read_n():
return int(sys.stdin.readline().strip())
def read_n_stamps():
return list(map(int, sys.stdin.readline().split()))
def solve(stamps: List[int], n: int = 0):
counts = defaultdict(int)
for stamp_type in stamps:
counts[stamp_type] += 1
ans = f"{n} "
for k in range(2, n + 1):
max_stamps = 0
for stamp_type in counts:
new_stamps = (counts[stamp_type] // k) * k
max_stamps += new_stamps
ans += f"{max_stamps}"
if k != n:
ans += " "
return ans
n = read_n()
stamps = read_n_stamps()
y = solve(stamps, n)
print(y)
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 28 29 30 31 32 | import sys from collections import defaultdict from typing import List def read_n(): return int(sys.stdin.readline().strip()) def read_n_stamps(): return list(map(int, sys.stdin.readline().split())) def solve(stamps: List[int], n: int = 0): counts = defaultdict(int) for stamp_type in stamps: counts[stamp_type] += 1 ans = f"{n} " for k in range(2, n + 1): max_stamps = 0 for stamp_type in counts: new_stamps = (counts[stamp_type] // k) * k max_stamps += new_stamps ans += f"{max_stamps}" if k != n: ans += " " return ans n = read_n() stamps = read_n_stamps() y = solve(stamps, n) print(y) |
English