# import collections def zna(): n = int(input()) a = list(map(int, input().split())) # def zna(n, a): #print(n, a) # print(collections.Counter(a).most_common()) zna_dict = {} zna_out = [0] * n for count, elem in sorted(((a.count(e), e) for e in set(a)), reverse=True): #print('%s (%d)' % (elem, count)) zna_dict[elem] = count # print(zna_dict) for i in range(1, n+1): if i == 1: zna_out[i-1] = n else: for key, value in zna_dict.items(): zna = value // i if zna >= 1: zna_out[i-1] += (zna * i) #return ' '.join( map(str,[9,8,6,4,0,0,0,0,0])) return ' '.join( map(str,zna_out)) #return zna_out if __name__ == '__main__': print(zna()) # print(zna(9,[1,1,777,42,777,1,42,1,777]))
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 | # import collections def zna(): n = int(input()) a = list(map(int, input().split())) # def zna(n, a): #print(n, a) # print(collections.Counter(a).most_common()) zna_dict = {} zna_out = [0] * n for count, elem in sorted(((a.count(e), e) for e in set(a)), reverse=True): #print('%s (%d)' % (elem, count)) zna_dict[elem] = count # print(zna_dict) for i in range(1, n+1): if i == 1: zna_out[i-1] = n else: for key, value in zna_dict.items(): zna = value // i if zna >= 1: zna_out[i-1] += (zna * i) #return ' '.join( map(str,[9,8,6,4,0,0,0,0,0])) return ' '.join( map(str,zna_out)) #return zna_out if __name__ == '__main__': print(zna()) # print(zna(9,[1,1,777,42,777,1,42,1,777])) |