HIT해
[JS 백준] 2563.색종이 본문
728x90
const input = require("fs")
.readFileSync(__dirname + "/input.txt")
.toString()
.trim()
.split("\n")
.map((x) => x.split(" ").map(Number));
let answer = 0;
let n = input.shift();
let xMax = -1;
let yMax = -1;
for (let i = 0; i < n; i++) {
xMax = Math.max(xMax, input[i][0] + 10);
yMax = Math.max(yMax, input[i][1] + 10);
}
let board = Array.from(Array(xMax), () => Array(yMax).fill(0));
for (let i = 0; i < n; i++) {
for (let j = input[i][0]; j < input[i][0] + 10; j++) {
for (let k = input[i][1]; k < input[i][1] + 10; k++) {
if (board[j][k] == 0) {
board[j][k] = 1;
answer++;
}
}
}
}
console.log(answer);
'Vue > JavaScript 알고리즘' 카테고리의 다른 글
[JS 백준] 1929.소수 구하기 (0) | 2024.01.06 |
---|---|
[JS 백준] 1978.소수찾기 (0) | 2024.01.05 |
[JS 백준] 10798.세로읽기 (0) | 2024.01.05 |
[JS 백준] 2443 단어 길이 재기 (0) | 2024.01.04 |
JavaScript (0) | 2023.05.16 |