# 72. 小朋友来自多少小区

72 72-1

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function(line) {
    const input = line.split(' ');
    const counts = [];
    let res = 0;
    input.forEach(child => {
        const children = parseInt(child);
        counts[children]++;
    })
    counts.forEach((count, i) => {
        if(count && count > 0) {
            const size = i + 1;
            // 累加小朋友的数量
            res += Math.ceil(count/size) * size;
        }
    })
    console.log(res);
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23