# 15. 爱吃蟠桃的孙悟空
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let arr;
function canfinish(arr, h, k) {
let ans = 0;
for(let v of arr) {
ans += Math.ceil(v/k);
}
return ans <= h;
}
rl.on('line', (line) => {
if(!arr) {
arr = line.split(' ').map(Number);
} else {
let h = parseInt(line);
if (n === 0 || h===0 || n > h) {
console.log(0);
return;
}
let left = 1;
let right = Math.max(...arr);
while (left < right) {
let k = Math.floor((left + right) / 2);
if (canfinish(arr, h, k)) {
right = mid;
} else {
left = mid + 1;
}
}
console.log(left);
}
});
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
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