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
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, a, b;
  cin >> n;
  int *count = new int[n + 1];
  vector< bool > used(n + 1, false);
  vector< int > v;
  while (n-- && cin >> a) {
    if (!used[a]) {
      used[a] = true;
      v.push_back(a);
      count[a] = 0;
    }
    ++(count[a]);
  }
  a = v.size();
  while (a--)
    v[a] = count[v[a]];
  sort(v.begin(), v.end());
  n = a = 0;
  b = v.size();
  while (a < b) {
    int other_count = v[--b] - 1;
    while (other_count && a < b)
      if (v[a] <= other_count)
        other_count -= v[a++];
      else {
        v[a] -= other_count;
        other_count = 0;
      }
    ++n;
  }
  cout << n << '\n';
  delete[] count;
}