K = int(input()) stamps = input().split(' ') def count_stamps(K, stamps): stamps_dict = dict() for stamp in stamps: if stamp in stamps_dict: stamps_dict[stamp] += 1 else: stamps_dict[stamp] = 1 stamps_dict = dict(sorted(stamps_dict.items(), key=lambda x:x[1], reverse=True)) max_k = stamps_dict[max(stamps_dict, key=stamps_dict.get)] results = [0]*K for k in range(1, max_k+1): result = 0 for city in stamps_dict: if stamps_dict[city] >= k: result += stamps_dict[city]-(stamps_dict[city]%k) else: break results[k-1] = result return ' '.join([str(x) for x in results]) print(count_stamps(K, stamps))
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 | K = int(input()) stamps = input().split(' ') def count_stamps(K, stamps): stamps_dict = dict() for stamp in stamps: if stamp in stamps_dict: stamps_dict[stamp] += 1 else: stamps_dict[stamp] = 1 stamps_dict = dict(sorted(stamps_dict.items(), key=lambda x:x[1], reverse=True)) max_k = stamps_dict[max(stamps_dict, key=stamps_dict.get)] results = [0]*K for k in range(1, max_k+1): result = 0 for city in stamps_dict: if stamps_dict[city] >= k: result += stamps_dict[city]-(stamps_dict[city]%k) else: break results[k-1] = result return ' '.join([str(x) for x in results]) print(count_stamps(K, stamps)) |