# 50. 求最多可以派出多少支团队
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let totalPeople;
let abilities;
let minAbility;
rl.on('line', function(line) {
if (!totalPeople) {
totalPeople = parseInt(line);
} else if (!abilities) {
abilities = line.split(' ').map(Number);
} else if (!minAbility) {
minAbility = parseInt(line);
abilities.sort((a, b) => a-b);
let left = 0;
let right = totalPeople - 1;
let res = 0;
while(left < right) {
if (abilities[right] >= minAbility) {
res += 1;
right -= 1;
} else if (abilities[right] + abilities[left] >= minAbility) {
res += 1;
right -= 1;
left += 1;
} else {
left += 1;
}
}
if (left === right && abilities[left] >= minAbility) {
res += 1;
}
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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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