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 <algorithm>
#define st first 
#define nd second
using namespace std;

pair <int, int> wyst[500005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
        wyst[i].nd = i;
    for(int i = 1; i <= n; i++)
    {
        int a;
        cin >> a;
        wyst[a].st++;
    } 
    sort(wyst, wyst + n + 1);
    int i = n, j = 1, counter = 0;
    while(j <= i)
    {
        counter++;
        int to_take = wyst[i].st - 1;
        while(j < i && to_take - wyst[j].st >= 0)
        {
            to_take -= wyst[j].st;
            j++;
        }
        if(j < i)
        {
            wyst[j].st -= to_take;
        }
        i--;
    }
    cout << counter;

    return 0;
}