def solve(): n=int(input()) inp = [eval(i) for i in input().split()] d={} for el in inp: if el in d: d[el]+=1 else: d[el]=1 d=sorted(d.values(), reverse=True) sum=0 cnt=0 for el in d: sum+=2*el-1 cnt+=1 if sum>=n: print(cnt) return solve()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | def solve(): n=int(input()) inp = [eval(i) for i in input().split()] d={} for el in inp: if el in d: d[el]+=1 else: d[el]=1 d=sorted(d.values(), reverse=True) sum=0 cnt=0 for el in d: sum+=2*el-1 cnt+=1 if sum>=n: print(cnt) return solve() |