import collections n = int(input()) tab = [int(x) for x in input().split()] counts = collections.defaultdict(int) for a in tab: counts[a] += 1 my_counts = sorted(list(counts.values()), reverse=True) accumulator = 0 for i, a in enumerate(my_counts): accumulator += 2 * a - 1 if accumulator >= n: print(i + 1) break
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import collections n = int(input()) tab = [int(x) for x in input().split()] counts = collections.defaultdict(int) for a in tab: counts[a] += 1 my_counts = sorted(list(counts.values()), reverse=True) accumulator = 0 for i, a in enumerate(my_counts): accumulator += 2 * a - 1 if accumulator >= n: print(i + 1) break |