Codeforces•May 28, 2025
Polycarp's Pockets
Hazrat Ali
Codeforces
Polycarp wants to distribute all the coins with the minimum number of used pockets. Help him to do that.
Input
The first line of the input contains one integer nn (1≤n≤1001≤n≤100) — the number of coins.
The second line of the input contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤1001≤ai≤100) — values of coins.
Output
Print only one integer — the minimum number of pockets Polycarp needs to distribute all the coins so no two coins with the same value are put into the same pocket.
Examples
Input
6
1 2 4 3 3 2
Output
2
Input
1
100
Output
1
Solution
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(100);
int ans = 0;
for (int i = 0; i < n; i++) {
int j;
cin >> j;
a[j - 1]++;
ans = max(ans, a[j - 1]);
}
cout << ans << "\n";
return 0;
}