#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
map<int, int> mp;
vector<int> v;
int otp = 1;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, a;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> a;
mp[a]++;
}
for (auto i : mp)
{
v.push_back(i.second);
}
sort(v.begin(), v.end());
for (int i = v.size(); i > 0; i--)
{
if (v[i] == v[i - 1])
{
otp++;
}
}
cout << otp;
return 0;
}
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 40 41 42 43 44 | #include <iostream> #include <map> #include <vector> #include <algorithm> using namespace std; map<int, int> mp; vector<int> v; int otp = 1; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, a; cin >> n; for (int i = 0; i < n; i++) { cin >> a; mp[a]++; } for (auto i : mp) { v.push_back(i.second); } sort(v.begin(), v.end()); for (int i = v.size(); i > 0; i--) { if (v[i] == v[i - 1]) { otp++; } } cout << otp; return 0; } |
English