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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
#include <cstdint>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    map<uint32_t, uint8_t> mp;
    uint32_t num {};
    uint32_t tmp {};
    uint32_t result {};

    cin >> num;

    for (uint32_t i {}; i < num; i++)
    {
        cin >> tmp;
        mp[tmp]++;
    }
//    for (auto &a: mp)
//        cout << a.first << ", " << static_cast<int>(a.second) << endl;
//
//    cout << "\n++++++++++++++++++++++++++++++++\n";

    vector<uint8_t> vec;
    for(const auto &pair: mp)
        vec.push_back(pair.second);

//    cout << "=====================================\n";
//    for(const auto &a: vec)
//        cout << static_cast<int>(a) << " ";

    sort(vec.begin(), vec.end(), greater<uint8_t>());

//    cout << "\n=====================================\n";
//    for(const auto &a: vec)
//        cout << static_cast<int>(a) << " ";

    while (!vec.empty())
    {
        tmp = vec.front() - 1;
        while (tmp > 0)
        {
            if (tmp >= vec.back())
            {
                tmp -= vec.back();
                vec.pop_back();
            }
            else
            {
                vec.back() -= tmp;
                tmp = 0;
            }
        }
        result++;
        vec.erase(vec.begin());
    }

    cout << static_cast<int>(result);

    return 0;
}