Advertisement
jbn6972

Untitled

Oct 15th, 2022
734
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. from collections import Counter
  2.  
  3. def findMinimumDistinct(A, N, K):
  4.     mp = Counter(A)
  5.     count = 0
  6.     length = 0
  7.     counts = []
  8.     for i in mp:
  9.         counts.append(mp[i])
  10.     counts = sorted(counts)
  11.     counts.reverse()
  12.      
  13.     for i in range(len(counts)):
  14.  
  15.         if (length >= K):
  16.             break
  17.          
  18.         length += counts[i]
  19.         count += 1
  20.  
  21.     print(count)
  22.  
  23. N,K = map(int,input().split())
  24. A = list(map(int,input().split()))
  25.  
  26. findMinimumDistinct(A, N, K)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement