# 36. 小明找位置

36

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

rl.on('line', function(input) {
    rl.on('line', function(num) {
        const xiaomingNumber = parseInt(num);
        const numbers = line.split(',').map(Number);
        numbers.sort((a,b)=>a-b);
        let left = 0;
        let right = numbers.length;
        let mid;
        while(left < right) {
            mid = Math.floor((left + right)/2);
            if (numbers[mid] < xiaomingNumber) {
                left = mid + 1;
            } else {
                right = mid;
            }
        }
        const position = left;
        console.log(position + 1);
    })
})

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