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
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
    int length;
    scanf("%d\n", &length);

    vector<int> counts(length, 0);

    for (int i = 0; i < length; i++) {
        int element;
        scanf("%d", &element);

        counts[element - 1]++;
    }

    sort(counts.begin(), counts.end());

    int elementsTaken = 0;
    int subseriesCount = 0;
    int i = length - 1;

    while (elementsTaken < length) {
        subseriesCount++;
        elementsTaken += (2 * counts[i] - 1);
        i--;
    }

    printf("%d\n", subseriesCount);

    return 0;
}