#include <queue>;
#include <vector>;
using namespace std;
class SortSecondary {
public:
bool operator()(vector<int> below, vector<int> above)
{
if (below[1] < above[1]) {
return true;
}
return false;
}
};
class Solution {
public:
int minSetSize(vector<int>& arr) {
int n = arr.size();
int n_half = floor((double)n / 2);
int resp = 0;
unordered_map<int, int> umap;
for(int num : arr) {
umap[num]++;
}
priority_queue<vector<int>, vector<vector<int>>, SortSecondary> maxHeap;
for (const auto & [ key, value ] : umap) {
maxHeap.push({key, value});
}
while(!maxHeap.empty() && n_half < n) {
vector<int> thisSet = maxHeap.top();
maxHeap.pop();
n -= thisSet[1];
resp++;
}
return(resp);
}
};