n = int(input()) series = input() def lid(n, series): series = series.split(' ') occur = dict() for elem in series: if elem in occur: occur[elem] += 1 else: occur[elem] = 1 count = 0 while(n>0): count += 1 most_freq_elem = max(occur, key=occur.get) n -= (occur[most_freq_elem]*2-1) occur[most_freq_elem] = 0 return count print(lid(n, series))
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | n = int(input()) series = input() def lid(n, series): series = series.split(' ') occur = dict() for elem in series: if elem in occur: occur[elem] += 1 else: occur[elem] = 1 count = 0 while(n>0): count += 1 most_freq_elem = max(occur, key=occur.get) n -= (occur[most_freq_elem]*2-1) occur[most_freq_elem] = 0 return count print(lid(n, series)) |