import sys n = int(sys.stdin.readline().rstrip()) a = [int(i) for i in sys.stdin.readline().split()] c = dict() for i in a: c[i] = c.get(i, 0) + 1 b = sorted(list(c.values()), reverse=True) k = 0 while n > 0: n -= 2 * b[k] - 1 k += 1 print(k)
1 2 3 4 5 6 7 8 9 10 11 12 13 | import sys n = int(sys.stdin.readline().rstrip()) a = [int(i) for i in sys.stdin.readline().split()] c = dict() for i in a: c[i] = c.get(i, 0) + 1 b = sorted(list(c.values()), reverse=True) k = 0 while n > 0: n -= 2 * b[k] - 1 k += 1 print(k) |