import sys def greaterThan0(x): if x > 0: return True else: return False count=int(input()) array=[] for i in input().split(): array.append(int(i)) numbers = {} for i in range(10): numbers[i]=0 for i in range(count): numbers[array[i]]= numbers[array[i]]+1 values = list(numbers.values()) values = list(filter(greaterThan0, values)) values.sort(reverse=True) result = 0 amount = 0 amount_remain = count for i in values: result = result + 1 amount = amount + i amount_remain = amount_remain - i if (amount > amount_remain): break print(result)
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 30 31 32 33 34 35 36 37 38 39 | import sys def greaterThan0(x): if x > 0: return True else: return False count=int(input()) array=[] for i in input().split(): array.append(int(i)) numbers = {} for i in range(10): numbers[i]=0 for i in range(count): numbers[array[i]]= numbers[array[i]]+1 values = list(numbers.values()) values = list(filter(greaterThan0, values)) values.sort(reverse=True) result = 0 amount = 0 amount_remain = count for i in values: result = result + 1 amount = amount + i amount_remain = amount_remain - i if (amount > amount_remain): break print(result) |