Skip to content

Commit e368d6a

Browse files
committed
89차 1번 문제풀이 (못품)
1 parent 22fc31e commit e368d6a

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

live8/test89/문제1/이상민.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const input = require("fs")
2+
.readFileSync(process.platform === "linux" ? "/dev/stdin" : "./input.txt")
3+
.toString()
4+
.trim()
5+
.split("\n");
6+
7+
const N = Number(input[0]);
8+
const arr = input.map(Number).splice(1);
9+
10+
arr.sort((a, b) => a - b);
11+
12+
let min = Number.MAX_SAFE_INTEGER;
13+
14+
for (let i = 0; i < N; i++) {
15+
const set = new Set([arr[i] + 1, arr[i] + 2, arr[i] + 3, arr[i] + 4]);
16+
let cnt = 0;
17+
for (let j = 0; j < N; j++) {
18+
if (set.has(arr[j])) cnt++;
19+
}
20+
min = Math.min(cnt, min);
21+
}
22+
23+
console.log(min);

0 commit comments

Comments
 (0)