n = int(input())
an = input()
an = an.split()
counts_dict={}
for a in an:
if a in counts_dict.keys():
counts_dict[a]+=1
else:
counts_dict[a]=1
counts = sorted(list(counts_dict.values()))
subsets = 0
while len(counts):
leader = counts.pop()
others = 0
while len(counts) and others+counts[0]<leader:
counts.pop(0)
subsets+=1
print(subsets)
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 | n = int(input()) an = input() an = an.split() counts_dict={} for a in an: if a in counts_dict.keys(): counts_dict[a]+=1 else: counts_dict[a]=1 counts = sorted(list(counts_dict.values())) subsets = 0 while len(counts): leader = counts.pop() others = 0 while len(counts) and others+counts[0]<leader: counts.pop(0) subsets+=1 print(subsets) |
English