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 MAX_N 10

using namespace std;

int main(){

    int n;
    scanf("%d", &n);
    int tab[MAX_N+1]={};

    for (int i = 0; i < n; i++){
        int temp;
        scanf("%d", &temp);
        tab[temp]++;
    }

    sort(tab, tab+MAX_N+1);

    // Now biggest numbers at the end

    int y=MAX_N;
    int subs = 0;
    int remaining = n;

    while(y!=0){
        int canceled = 0;
        int itx = 0;

        while(tab[y]*2 < remaining-canceled){
            canceled += tab[itx];
            itx++;
        }
        y = itx;
        subs++;
        remaining = canceled;
    }
    printf("%d\n",subs);
    /*for (int i = 0; i<=MAX_N; i++){
        cout<<i<<" "<<tab[i]<<endl;
    }*/
    return 0;
}