You are viewing a single comment's thread. Return to all comments →
using namespace std; int test(int n, vector a){ unordered_map v; for(int it : a){ v[it]++; } int max_value = 0; for(auto& pair : v){ max_value = max(max_value, pair.second); } return n - max_value; } int main(){ int n; cin >> n; vector a(n); for(int i = 0; i < n; i++){ cin >> a[i]; } cout << test(n, a) << endl; return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Equalize the Array
You are viewing a single comment's thread. Return to all comments →
include
using namespace std; int test(int n, vector a){ unordered_map v; for(int it : a){ v[it]++; } int max_value = 0; for(auto& pair : v){ max_value = max(max_value, pair.second); } return n - max_value; } int main(){ int n; cin >> n; vector a(n); for(int i = 0; i < n; i++){ cin >> a[i]; } cout << test(n, a) << endl; return 0; }