Skip to content

Commit 6eb5f19

Browse files
[BOJ] 27532 시계 맞추기 (G5)
1 parent a3a2064 commit 6eb5f19

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

서정우/6주차/260203.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const fs = require("fs");
2+
const filePath = process.platform === "linux" ? "/dev/stdin" : "./서정우/input.txt";
3+
const input = fs.readFileSync(filePath).toString().trim().split("\n");
4+
5+
const N = Number(input[0]);
6+
7+
const lines = input.slice(1);
8+
const totalMinutes = lines.map((time) => {
9+
const [H, M] = time.split(":").map(Number);
10+
const totalMinutes = H * 60 + M;
11+
return totalMinutes % 720;
12+
});
13+
14+
let minClocks = N;
15+
16+
for (let r = 0; r < 720; r++) {
17+
const clockTimes = new Set();
18+
19+
for (let i = 0; i < N; i++) {
20+
const clockTime = (totalMinutes[i] - ((i * r) % 720) + 720) % 720;
21+
22+
clockTimes.add(clockTime);
23+
}
24+
25+
minClocks = Math.min(minClocks, clockTimes.size);
26+
}
27+
console.log(minClocks);

서정우/input.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
1
2-
$
1+
5
2+
03:05
3+
12:40
4+
03:25
5+
03:25
6+
01:10

0 commit comments

Comments
 (0)