We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 105ed24 commit e196038Copy full SHA for e196038
1 file changed
live8/test84/문제2/황장현.js
@@ -7,8 +7,25 @@ const input = require('fs')
7
8
function solution(input) {
9
const [K, N] = input[0];
10
- const lanList = input.slice(1).flat();
11
- if (K >= N) return Math.max(...lanList);
+ const lanList = input.slice(1);
+
12
+ let low = 1;
13
+ let high = Math.max(...lanList);
14
+ let answer = 0;
15
16
+ while (low <= high) {
17
+ let mid = Math.floor((low + high) / 2);
18
+ let count = lanList.reduce((acc, cur) => acc + Math.floor(cur / mid), 0);
19
20
+ if (count >= N) {
21
+ answer = mid;
22
+ low = mid + 1;
23
+ } else {
24
+ high = mid - 1;
25
+ }
26
27
28
+ return answer;
29
}
30
31
console.log(solution(input));
0 commit comments