//
// main.cpp
// lid
//
// Created by Mikołaj Małysz on 12/03/2024.
//
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(int argc, const char * argv[]) {
int n;
cin >> n;
vector<int> count(n, 0);
int temp;
for (int i = 0; i<n; i++) {
cin >> temp;
count[temp-1]++;
}
sort(count.begin(), count.end());
int res = 1;
for (int i = n-1; i>0; i--) {
//cout << count[i] << endl;
if (count[i] == count[i-1]) {
res++;
} else {
break;
}
}
cout << res << endl;
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 | // // main.cpp // lid // // Created by Mikołaj Małysz on 12/03/2024. // #include <iostream> #include <vector> #include <algorithm> using namespace std; int main(int argc, const char * argv[]) { int n; cin >> n; vector<int> count(n, 0); int temp; for (int i = 0; i<n; i++) { cin >> temp; count[temp-1]++; } sort(count.begin(), count.end()); int res = 1; for (int i = n-1; i>0; i--) { //cout << count[i] << endl; if (count[i] == count[i-1]) { res++; } else { break; } } cout << res << endl; return 0; } |
English