diff --git "a/27. \355\203\220\354\232\225\353\262\225/BOJ/1449.js" "b/27. \355\203\220\354\232\225\353\262\225/BOJ/1449.js" new file mode 100644 index 0000000..a54062c --- /dev/null +++ "b/27. \355\203\220\354\232\225\353\262\225/BOJ/1449.js" @@ -0,0 +1,25 @@ +const filePath = process.platform === "linux" ? "/dev/stdin" : "./input.txt"; +const input = require("fs").readFileSync(filePath).toString().split("\n"); + +// const [N, L] = input[0].split(" "); // N: 물이 새는 곳의 개수, L: 테이프 길이 +const N = +input[0].split(" ")[0]; // 물이 새는 곳의 개수 +const L = +input[0].split(" ")[1]; // 테이프 길이 + +const pos = input[1] + .split(" ") + .map(v => +v) + .sort((a, b) => a - b); + +let current = 0; +let end = 0; +let result = 0; + +while (current < N) { + if (end < pos[current]) { + end = pos[current] + L - 0.5; + result++; + } + current++; +} + +console.log(result);